locked
Silverlight web resource RRS feed

  • Question

  • I am finding difficulty while updating a record in a silverlight web resource.

    The message is as follows

    "<?xml version=\"1.0\" encoding=\"utf-8\" standalone=\"yes\"?>\r\n<error xmlns=\"http://schemas.microsoft.com/ado/2007/08/dataservices/metadata\">\r\n  <code></code>\r\n  <message xml:lang=\"en-US\">Forbidden</message>\r\n</error>"

     

    I am using CRM 2011 online for the purpose.

    What may be the reasons?

    Can anyone help me out here?


    Dibyasingh Tripathy
    Friday, January 20, 2012 1:51 PM

Answers

  • I would check out fiddler and see if you can't get anymore detail on the error that is happening.

    Here's some introductory links if you haven't used it before in the context of CRM: 

    http://blog.sonomapartners.com/2012/01/fiddling-with-crm.html

    http://blogs.msdn.com/b/crminthefield/archive/2011/05/19/using-fiddler-http-debugger-for-crm-troubleshooting-and-performance-tuning.aspx

    Wednesday, January 25, 2012 10:28 PM

All replies

  • Hi,

    I guess you create a webservice client in your silverlight app and call the update method for a specific data, right?!

    Check if the actual user who call the method from the silverlight app has enough privileges to update the data!

    Greets,

    Andreas


    Andreas Buchinger
    Microsoft Dynamics Certified Technology Specialist
    MCPD: SharePoint Developer 2010
    Friday, January 20, 2012 2:18 PM
  • If Andreas' answer doesn't appear to solve it then something else might be the issue...

    Note that you should be marshalling your data call out on the UI thread. Something funky happens in silverlight where when you make a call in the background thread the cookies aren't shared all the time so it actually loses your authentication to CRM. This may apply for hosted/IFD CRM environments as well. So what actually may be happening here is that your data call is being redirected to the login page and failing.

     

    Saturday, January 21, 2012 4:09 AM
  • @Andreas I am totally new with silverlight as well as the MS CRM dynamics.

    So what are the steps I need to follow if thats what is happening as you said?


    Dibyasingh Tripathy
    Saturday, January 21, 2012 5:56 AM
  • And if I will add again the service reference from other organization's odata service after deleting the previous service reference to the Odata service from another prganization then will it be an issue?

    Note: In both the cases I have the same user previllege


    Dibyasingh Tripathy
    Saturday, January 21, 2012 5:59 AM
  • Hi dibbs

    Please elaborate about what you are writing cause I am a new comer in this platform and I think what you wrote is the problem that I am getting.But I don't have any idea how to overcome the problem.Please guide me here.Its already a big tension for me.I need to solve this.As this is what is gonna give me a little confidence in the field. So please let me know how to get rid of this problem.

     

    I am getting the message while invoking the context_EndsaveChanges(result).

    I tried everything that a new comer can do.

     


    Dibyasingh Tripathy
    Saturday, January 21, 2012 5:20 PM
  • So you're silverlight application has multiple threads, one of them is called the "UI" thread. This is the thread you need to execute you're call through. So basically you would need to wrap your call so that it executes on the UI thread. Here is a sample: http://www.silverlightshow.net/items/How-to-invoke-method-in-the-UI-thread.aspx

     

    Saturday, January 21, 2012 6:34 PM
  • Hi dibbs,

    Well I tried using dispatcher.begininvoke too.But it didn't work.I am getting the same error again..

     

    Please see the code below which I have written.I don't have any idea where am I taking the wrong move?

     

     private void BeginSaveChanges()
            {
                Dispatcher.BeginInvoke(() =>
                   {
                       try
                       {
                           ActivityPointer act = new ActivityPointer();
                           act = (ActivityPointer)ActivityDataGrid.SelectedItem;
                           // _context.AttachTo("AccountSet", act);
                           _context.UpdateObject(act);
                           _context.BeginSaveChanges(OnSaveActivitiesComplete, act);
                           //Invokes context to save the changes
                           // _context.BeginSaveChanges(OnSaveActivitiesComplete, TheMainViewModel.Activities);
                       }
                       catch (SystemException se)
                       {
                           MessageBox.Show(se.Message.ToString());
                       }
                   });
            }

            /// <summary>
            /// Asynchronously called in order to save the changes.
            /// </summary>
            /// <param name="result"></param>

            private void OnSaveActivitiesComplete(IAsyncResult result)
          {
              Dispatcher.BeginInvoke(() =>
                 {
                     try
                     {
                         //Complete the save
                         _context.EndSaveChanges(result);
                     }
                     catch (SystemException se)//Here I am getting the exception saying that it is forbidden.
                     {
                         MessageBox.Show(se.Message.ToString());
                     }
                 });
          }

    Please recommend me any other ideas that might help.

    Thank you in advance..


    Dibyasingh Tripathy
    Monday, January 23, 2012 10:38 AM
  • Hi dibbs,

    I fixed the error.It was my mistake.Though I was doing the right thing but I was not notifying that the property has been changed.Thats why I was getting the error.Now that error is fixed but now I am getting another error.Please have a look at that.

     

    {System.InvalidOperationException: An error occurred while processing this request. ---> System.Data.Services.Http.WebException: Internal error at 'HttpWebResponse.NormalizeResponseStatus'.
       at System.Data.Services.Http.XHRHttpWebResponse.NormalizeResponseStatus(Int32& statusCodeParam)
       at System.Data.Services.Http.XHRHttpWebResponse..ctor(XHRHttpWebRequest request, Int32 statusCode, String responseHeaders)
       at System.Data.Services.Http.XHRHttpWebRequest.CreateResponse()
       at System.Data.Services.Http.XHRHttpWebRequest.EndGetResponse(IAsyncResult asyncResult)
       at System.Data.Services.Client.SaveResult.AsyncEndGetResponse(IAsyncResult asyncResult)
       --- End of inner exception stack trace ---
       at System.Data.Services.Client.BaseAsyncResult.EndExecute[T](Object source, String method, IAsyncResult asyncResult)
       at System.Data.Services.Client.DataServiceContext.EndSaveChanges(IAsyncResult asyncResult)
       at SilverlightActivityEditorModified.MainPage.<>c__DisplayClass27.<OnSaveActivitiesComplete>b__26()}

     

    Is there anything you can suggest here?

    Thank you.


    Dibyasingh Tripathy
    Monday, January 23, 2012 1:05 PM
  • Hi,

    I think you set an status on your data that is not possible - check the status of the data that is being saved!

    Check the following link containing the possible state values: http://msdn.microsoft.com/en-us/library/ms914670.aspx

    Greets,

    Andreas


    Andreas Buchinger
    Microsoft Dynamics Certified Technology Specialist
    MCPD: SharePoint Developer 2010
    Monday, January 23, 2012 1:35 PM
  • Hi Andreas,

    I checked the status of the modified activity entity.But the status and state both are same as the retrieved entity and the status is open as I am retrieving only active and open entites.I don't have any idea why it is giving this error.Still stuck with the same error.

    Suggest me any other options if you have any.

    Thank you


    Dibyasingh Tripathy
    Tuesday, January 24, 2012 7:16 AM
  • Hi,

    I think the error regards the Silverlight-app and not the data service from crm - look at this thread: http://stackoverflow.com/questions/1572919/self-hosted-ado-net-data-services-comsuming-from-an-external-silverlight-applic . This is only one out of many who has the same problem. It's only a suggestion from me but try to place a clientaccesspolicy and a crossdomainpolicy in the root domain of crm - perhaps the problem is a crossdomain call in the background...

    Greets,

    Andreas


    Andreas Buchinger
    Microsoft Dynamics Certified Technology Specialist
    MCPD: SharePoint Developer 2010
    Tuesday, January 24, 2012 9:39 AM
  • Hi Andreas,

    Well I am using crm2011 online so I can't use the clientaccesspolicy and crossdomain xmls.

    I think we can't update an activity record directly.When I am trying to update account/contact records,it is getting updated but when I am trying to update an activity record by following the same procedure,its not getting updated.

    Anyways thanks for replying and giving attention.

     


    Dibyasingh Tripathy
    Tuesday, January 24, 2012 9:46 AM
  • I would check out fiddler and see if you can't get anymore detail on the error that is happening.

    Here's some introductory links if you haven't used it before in the context of CRM: 

    http://blog.sonomapartners.com/2012/01/fiddling-with-crm.html

    http://blogs.msdn.com/b/crminthefield/archive/2011/05/19/using-fiddler-http-debugger-for-crm-troubleshooting-and-performance-tuning.aspx

    Wednesday, January 25, 2012 10:28 PM
  • Hi,

    Have you ever checked by enabling the server tracing if more detailed error messages come out on server? Perhaps it's a problem regarding the privileges of the calling user...?

    Greets,

    Andreas


    Andreas Buchinger
    Microsoft Dynamics Certified Technology Specialist
    MCPD: SharePoint Developer 2010
    Monday, February 6, 2012 6:57 PM
  • Hello Andreas and Dibbs

    Andreas,well I am the administrator of the CRM live account.And I have all of the previlleges with me.:)

    Well I did the update part.Though it is throwing the exception(I don't know why).But the data are getting updated.

    Thanks all for your attention.

    I would like to use fiddler sometimes.

    Thanks..


    Dibyasingh Tripathy

    Saturday, February 11, 2012 9:20 AM
  • Hi Dibbs

    I would like to thank you for introducing me to the fiddling concept..It helped me a lot..Thank you once again


    Dibyasingh Tripathy

    Tuesday, February 21, 2012 9:55 AM