Error processing request stream. The request should be a valid top-level resource object CRM and oData

Hi,

Today I got the below error when I was trying to update Product Properties using Java Script.

Error processing request stream. The request should be a valid top-level resource object

The code is as follows.

function updateProductProperties() {
   var vUpdateProperty = {};
   vUpdateProperty.ValueString = “testing”;
   vUpdateProperty.DynamicPropertyId = “guid”;
   vUpdateProperty.RegardingObjectId = “guid”
   var vdynamicProductPropertyId = “”;
   SDK.REST.updateRecord(vdynamicProductPropertyId, vUpdateProperty, “DynamicPropertyInstance”, function () { alert(“The dynamic property instance record changes were saved”); }, function (error) { alert(error.message); });
}

After some search I figured out the error was because of type mismatch. When you get this type of error check the fields are mapped to correct data type references. In my case, I need to use Entity Reference Object where I used normal string.

Here is the correct code.


function updateProductProperties() {
    var vUpdateProperty = {};
    vUpdateProperty.ValueString = “testing”;
    vUpdateProperty.DynamicPropertyId = { Id: “”, LogicalName: “dynamicproperty” };
    vUpdateProperty.RegardingObjectId = { Id: “”, LogicalName: “opportunityproduct” };
    var vdynamicProductPropertyId = “”;
    SDK.REST.updateRecord(vdynamicProductPropertyId, vUpdateProperty, “DynamicPropertyInstance”, function () { alert(“The dynamic property instance record changes were saved”); }, function (error) { alert(error.message); });
}

Hope this helps.


Happy CRM’ing

Gopinath

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s