'Multiple Headers required using RetailWebRequest AX 2012

I need to be able to pass 2 headers via the RetailWebRequest.parmHeaders() in AX2012. I have both a subscription-key and bearer token I need to pass to the endpoint URI to enable successful retrieving on data.

Do i need to build a string and pass that via the parmHeaders method? My current code below;

request2 = RetailWebRequest::newUrl("MyURL");
request2.parmHeader("Ocp-Apim-Subscription-ey:"MySubKey");
request2.parmContentType("application/json");
request2.parmMethod("GET");
response2 = webAPI2.getResponse(request2);
rawResponse = response2.parmData();

If i just pass the header string shown, it accepts but gives me the error of not having a valid bearer key. This is where i need to pass 2 headers.

If there's another track i need to head down then any advice would be grateful!



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source