I’ve recently had a requirement to integrate an external system (Toggl www.toggl.com) 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)
str rawResponse, value;
RetailCommonWebAPI webApi = RetailCommonWebAPI::construct();
request = RetailWebRequest::newUrl("http://mysite.com/jsonaction");
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.