Using JSON in Dynamics AX

22 10 2013

I’ve recently had a requirement to integrate an external system (Toggl with Dynamics AX 2012’s Timesheet system. However the external system only provided a JSON API which isn’t supported natively by the Dynamics AX AIF system.  After some research and trial and error (using various DLL’s) I eventually stumbled across some really useful classes provided by the Retail module in Dynamics AX2012. These classes (although named “Retail…”) provide a really easy and elegant JSON interaction for any use. Here is a very basic code sample of how to consume JSON using these classes in Dynamics AX 2012.


static void myJob(Args _args)
    RetailWebRequest request; 
    RetailWebResponse response; 
    str rawResponse, value; 
    Map data; 
    RetailCommonWebAPI webApi = RetailCommonWebAPI::construct(); 
    request = RetailWebRequest::newUrl(""); 
    response = webApi.getResponse(request); 
    rawResponse = response.parmData(); 
    data = RetailCommonWebAPI::getMapFromJsonString(rawResponse); 
    value = data.lookup("elementname"); 
    info(strFmt("Element name: %1",value)); 

If you are interested in some more advanced examples of using JSON in AX (e.g. using authentication, retrieving subsets of info or arrays)  or doing some of your own integration into Toggl timekeeping please let me know and I’ll post some more info.




13 responses

23 10 2013

Thanks for interesting post!!! I’m very interesting about of advanced using JSON in AX 2012. Please send me examples of usage. Thanks!!!

8 11 2013

I’m interested in making by sending json object as input. Is this possible? If you could you please send me some example, that would be great! Thanks!

8 11 2013

making requests*

11 11 2013
JSON in Dynamics AX – Advanced example #1 (Basic Auth) | Dynamics AX Workflow Wanderings

[…] my previous post on using JSON in Dynamics AX2012 I have received a number of requests for some slightly more […]

15 03 2014
david aronbwrg

We are interested in Dynamics AX but what is holding us back is an elegant time tracking component like toggl or harvest. Does someone know one out there that natively integrates or can you share what you did with toggl.

13 08 2014
Using JSON in Dynamics AX | Explore

[…] Repost from: […]

15 09 2014

I am getting an error when I use this code. Clr object could not be created. Pls help.

31 12 2014

Thank you for this excellent article. I have used your example for a few other examples at my blog post: (artcicle gets published January 1st. 2015)

1 01 2015
Testing JSON from AX 2012 - Microsoft Dynamics AX Community

[…] 31 Dec 2014 5:00 PM I wanted to see how JSON could be consumed from AX, and found this great article from Jonathan.Then I needed something to test with and found the site so, here are […]

7 01 2015

Do you happen to have an example with authentication?
Thanks for this great post!

18 02 2016
Baqer Naqvi

I have managed to get JSON string in AX using .net dlls and Newtonsoft. Now I don’t know how to desalinize. Hep will be appreciated.

18 02 2016
Frank HusterFrank

If you use Newtonsoft … Here is a sample of my code:

str postData;
JsonWebResponse response;
EmarsysJson.WebResponse.GetContactResponse getContactResponse;

postData = Newtonsoft.Json.JsonConvert::SerializeObject(contactData, Newtonsoft.Json.Formatting::Indented);

response = this.makePostRequest(jsonUriTable.URI, postData);

getContactResponse = new EmarsysJson.WebResponse.GetContactResponse();
getContactResponse = Newtonsoft.Json.JsonConvert::DeserializeObject(response.parmData(), getContactResponse.GetType());

30 07 2017
tallapoosa entertainment center

Hi there to every body, it’s my first visit of
this blog; this weblog includes awesome and genuinely excellent stuff
in favor of readers.

Leave a Reply

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

You are commenting using your 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

%d bloggers like this: