Hi
I'm trying to do a POST Rest call to the computer vision service of the Azure Cognitive services in the new development environment in AL using the HTTPClient as seen in the example of this blog post
http://www.kauffmann.nl/2017/06/24/al-support-for-rest-web-services/.
When using the code underneath I'm having the issue that I cannot pass my "Content Type" header as it gives me the following error. "Misused header name. Make sure request headers are used with HttpRequestMessage, response headers with HttpResponseMessage, and content headers with HttpContent objects."
When I do not specify this header the Webservice returns "Unsupported media Type" so I'm guessing this header is required.
Do you have any idea how I am able to pass this header in my REST Call to the webservice?
actions
{
addafter("Bank Accounts"){
action(Test)
{
trigger OnAction();
var
HttpClient:HttpClient;
content:HttpContent;
ResponseMessage:HttpResponseMessage;
headers:HttpHeaders;
begin
HttpClient.DefaultRequestHeaders.Add('Ocp-Apim-Subscription-Key','****************************');
// HttpClient.DefaultRequestHeaders.Add('Content-Type','application/json');
content.WriteFrom('{"url": ' + '"' + '
https://www.goodmorningquote.com/wp-content/uploads/2015/03/best-good-morning-quotes-and-images.jpg' + '"}');
//content.GetHeaders(request);
HttpClient.Post('
https://westeurope.api.cognitive.microsoft.com/vision/v1.0/ocr?language=unk&detectOrientation =true',content,ResponseMessage);
Message(ResponseMessage.ReasonPhrase());
end;
}// Add changes to page actions here
}
}