Dear All,
I have Json API with Key and Value as Authorisation and Ineed to get the data from API using the key and value by X++ code and send them response. I also need to send data to API web services using Json using secret key and value.
Environemnt : AX 2012 R3
Code:
static void MYAPITest(Args _args)
{
RetailWebRequest request;
RetailWebResponse response;
str rawResponse, value;
str _startDate, _endDate;
Map data;
#define.ServiceURL(API URL Link)
#define.APIkey("MYKEY")
RetailCommonWebAPI webApi = RetailCommonWebAPI::construct();
request = RetailWebRequest::newUrl(#ServiceURL);
request.parmHeader(@"'x-apiKey','MYKEY', 'x-secret', 'MYVALUE'");
request.parmContentType(@"application/json; encoding='utf-8");
request.parmMethod("GET");
response = webApi.getResponse(request);
rawResponse = response.parmData();
data = RetailCommonWebAPI::getMapFromJsonString(rawResponse);
value = data.lookup("employeeId");
info(strFmt("Employee Id: %1",value));
}
Cause of Error ( Assumption) : I do not know how to pass key and value that make valid key for API.