RE: Dynamics 365 BC -SOAP service OAuth Authentication
Hello Nitin,
Thanks for the reply.
I am using the below code to integrate to Purchase Invoice using SOAP web service and auth authentication. AuthTocket tocken return successfully from my another function and I am passing Purchase Invoice object and Tocken to the below code.
var myContent = JsonConvert.SerializeObject(purchaseInvoice);
var buffer = System.Text.Encoding.UTF8.GetBytes(myContent);
var byteContent = new System.Net.Http.ByteArrayContent(buffer);
byteContent.Headers.ContentType = new System.Net.Http.Headers.MediaTypeHeaderValue("application/json");
using (System.Net.Http.HttpClient client = new System.Net.Http.HttpClient())
{
client.DefaultRequestHeaders.Add("Authorization", "Bearer " + AuthToken);
var result = client.PostAsync(dynamicsWebServiceURL, byteContent).Result;
if (result.IsSuccessStatusCode)
{
Console.WriteLine(result.Content.ReadAsStringAsync().Result);
}
}
But, for the highlighted line, I am getting error as below.
{StatusCode: 415, ReasonPhrase: 'Unsupported Media Type', Version: 1.1, Content: System.Net.Http.StreamContent, Headers:
{
Transfer-Encoding: chunked
Access-Control-Allow-Headers: Origin, X-Requested-With, Authorization
Access-Control-Allow-Origin: *
Access-Control-Allow-Credentials: true
ms-correlation-x: e46003d6-1968-4e51-88e2-92e01abde14b
x-content-type-options: nosniff
Strict-Transport-Security: max-age=31536000; includeSubDomains
Access-Control-Expose-Headers: ms-correlation-x
Date: Mon, 09 May 2022 11:25:18 GMT
Server: Microsoft-HTTPAPI/2.0
}}
Could you please help to resolve this error?