Hello there,
Is there any way that I can copy JSON value and insert into dynamics nav table,
Here is the sample JSON response. I am doing this in Dynamics NAV 2013. Initially I copied values using SELECTSTR but is there any proper way to do this.
{
"result": {
"addresses": [
{
"city": "8888",
"address1": "*******",
"postalCode": "***",
"type": "BT",
"companyName1": "Z*****.",
"recordId": "BT",
"state": "NV",
"locationNumber": "**T",
"dunsNumber": "*T"
},
{
"country": "US",
"address2": "********",
"city": "New York",
"address1": "***************,
"postalCode": "**",
"type": "RE",
"companyName1": "***",
"recordId": "RE",
"state": "NY",
"locationNumber": "6*0",
"dunsNumber": "6*"
},
],
Thanks
0
Answers
You need to get the add-in Newtonsoft.Json from the NAV 2016 version too and copy in the add-in folder of the NAV 2013 version.
These are the objects.
And here there is a link to a zip file with the objects in NAV 2013, a report using the JSON data you posted, a file with the jason data and the add-in in the Json folder.
https://www.dropbox.com/s/9tehsgomd5ms7o8/json_datos_2013.zip?dl=1
Regards.
Thank you so much for you effort. It is really worth. After all I got following error. Do you know where I missed. ?
Microsoft Dynamics NAV
This message is for C/AL programmers: Cannot create an instance of the following .NET Framework object: assembly Newtonsoft.Json, Version=7.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, type Newtonsoft.Json.JsonConvert.
OK
Did you copy the Json fiolder in the zip file inside the Add-ins folder of the service ?
Usually this:
Regards
You should duplicate the previous functions, change the names and parameters and then call the function GenerateStructureFromText with the Text var where is the JSON data.
Regards.
No PM,please use the forum. || May the <SOLVED>-attribute be in your title!
I have done as your code. But When I pass the request, I am getting this error. Could you please guide me where I wrong .
Microsoft Dynamics NAV
A call to Newtonsoft.Json.JsonConvert.DeserializeXmlNode failed with this message: JSON root object has multiple properties. The root object must have a single property in order to create a valid XML document. Consider specifing a DeserializeRootElementName. Path 'message', line 1, position 15538.
OK
Looks like the problem is with the Json text.
Could you post how are you filling the text variable with the json data and the real json data ?
Regards.
I just call the rest web-service and call the relevant function,then I will get the response, Same response I will pass into GenerateStructureFromText
Request := RequestClass.XMLHTTPRequestClass;
Request.open('GET',MySetup."APIEndpoint"+'documents/order/'+ID,FALSE,'','');
Request.setRequestHeader('Content-Type',ContentType);
Request.setRequestHeader('sessionId',UserSessionID);
Request.send('');
IF Request.status = 200 THEN BEGIN
GenerateStructureFromText(Request.responseText,TempXMLBuf,True);
END;
I use message to check the response text. I am getting the data.
The problem is that your Json data don't have a root item
Maybe the best way is to wrap the Request.responseText with a root Item, something like this:
Regards
The right call is this one:
You need to remove the second curly brace.
Regards.
It's really working for me. Thanks a lot!