Hi All,
I am trying to post JSON data to the plugin via ajax. I am getting an error with 400 error code and the exception message as :
An error occurred while validating input parameters: Microsoft.OData.ODataException: An unexpected 'StartObject' node was found for property named 'ShipmentDetails' when reading from the JSON reader. A 'PrimitiveValue' node was expected.
The code is
var data = { "IsCreateShipmentTask": true }; data.ShipmentDetails = PrepareShipmentData(); var jsonData = JSON.stringify(data); $.ajax({ url: organizationUrl + "/api/data/v9.1/" + query, type: 'POST', contentType: "application/json; charset=utf-8", async: false, datatype: "json", data: jsonData, beforeSend: function (XMLHttpRequest) { //Specifying this header ensures that the results will be returned as JSON. XMLHttpRequest.setRequestHeader("Accept", "application/json"); }, success: function (responseText) { } });
If I modify the above JSON payload & make it as
data = { "IsCreateShipmentTask": true, "ShipmentDetails" : "some value" };
then it's working. But not with JSON objects.
Please help me out of this issue.
Thanks
*This post is locked for comments