Hi all,
I want to call external api from navision
I have used below code
CallRESTWebServiceFinal(BaseUrl : Text;Method : Text;RestMethod : Text;HttpContent : DotNet "System.Net.Http.HttpContent";HttpResponseMessage : DotNet "System.Net.Http.HttpResponseMessage")
HttpClient := HttpClient.HttpClient();
HttpClient.DefaultRequestHeaders.Add('Username', 'username');
HttpClient.DefaultRequestHeaders.Add('Password', 'password');
HttpClient.DefaultRequestHeaders.Add('ContentType', 'application/json');
HttpClient.BaseAddress := Uri.Uri(BaseUrl);
CASE RestMethod OF
'GET':
HttpResponseMessage := HttpClient.GetAsync(Method).Result;
'POST':
HttpResponseMessage := HttpClient.PostAsync(Method,HttpContent).Result;
'PUT':
HttpResponseMessage := HttpClient.PutAsync(Method,HttpContent).Result;
'DELETE':
HttpResponseMessage := HttpClient.DeleteAsync(Method).Result;
END;
HttpResponseMessage.EnsureSuccessStatusCode(); // Throws an error when no success
CallAPIFunction()
SubUrl:='suburl';
ServicePointManager.SecurityProtocol:=SecurityProtocolType.Tls12;
CallRESTWebServiceFinal('MainURL',SubUrl,'GET',null,HttpResponseMessage);
result := HttpResponseMessage.Content.ReadAsStringAsync.Result;
But I'm getting below error
unsupported media type
please help