Hubert Solecki Hubert Solecki - 1 year ago 87
JSON Question

Posting data using javascript with ODATA format

I'm facing an issue when converting ODATA string into JSON while posting on my Dynamics CRM.
When I'm trying to serialize that way:

var phoneCallAssociationJsonData = '{'
+'"" : "'+ phoneCallUid +')"'

And serialize it in the request like that: JSON.stringify(phoneCallAssociationJsonData);

I get a BAD REQUEST response. But When I use POSTMAN to post data and I copy the following JSON:

{"" : ""}

It works perfectly.
Does someone know if there is a special way way to serialize string with odata format ?

I've tried to create a javascript object but adding a is not possible because @ is not an allowed character.

Answer Source

Firstly, rather than creating a string, which you then stringify, create an OBJECT

var phoneCallAssociationJsonData = {
    "" : ""+ phoneCallUid +")"



should now work

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download