Problem initiating the update fields action: Error processing request stream. The request should be a valid top-level resource object. RRS feed

  • Question

  • Hi,

    I am trying to update a  optionset field 


    caMerge.UpdateCustomerRecord = function (recordId, fields) {

                                      var deferred = new $.Deferred();
                                          type: "POST",
                                          contentType: "application/json; charset=utf-8",
                                          datatype: "json",
                                          data: window.JSON.stringify(fields),
                                          url: Xrm.Page.context.prependOrgName(scriptStrings.ODataPath+"ContactSet(guid'" + recordId + "')"),
                                          beforeSend: function (xmlHttpRequest) {
                                              xmlHttpRequest.setRequestHeader("Accept", "application/json");
                                              xmlHttpRequest.setRequestHeader("X-HTTP-Method", "MERGE");
                                          success: function (msg) {
                                          error: function (error) {                                        

                                      return deferred.promise();

    Can anyone point me in the right direction? Thanks,

    Monday, July 20, 2015 8:51 PM

All replies

  • Hello,

    Could you please provide parameters that you pass to UpdateCustomerRecord function and what is scriptStrings.ODataPath?

    Dynamics CRM MVP
    My blog

    Wednesday, July 22, 2015 11:24 AM
  • Hi,

    The issue was,I was sending an entity reference object value as string in 'fields'. If anyone is having this  issue make sure that you are passing appropriate objects, for example:

    CurrentOwner_ContactId = { __metadata: { type: "Microsoft.Crm.Sdk.Data.Services.EntityReference" }, Id:  bId };


    FinancialRecordType = { __metadata: { type: "Microsoft.Crm.Sdk.Data.Services.OptionSetValue" }, Value: financialRecord.RecordType };

    FYI...same with currency fields too...

    Hope this helps

    Monday, August 17, 2015 5:07 PM