Currently I have SOAP calls into D365 F&O to retrieve and update data. This is working correctly.
We have a concern with the longevity and performance of SOAP, so I am trying to convert the SOAP into Web API. The SOAP calls into the AOT / X++ code, both our custom code and base D365 code for the data reads and updates. We need to be able to maintain reading these code sets to maintain the use of business logic and not having to re-write the entire application. I have copied the code below.
It is returning a response of:
"Message": "An exception occured when deserializing a parameters - Exception occured when parsing the request content - Error reading JObject from JsonReader.
Current JsonReader item is not an object: StartArray. Path '', line 1, position 1.",
"ExceptionType": "XppServicesDeserializationException",
"ActivityId": "1b9ca4c9-b2ff-0004-68a9-9c1bffb2d801"
I have verified that postContentTest variable is a legit JSON object.
using (var clientWebAPI = CreateClient(DynamicsURI, AccessToken))
{
var postContentTest = JsonConvert.SerializeObject(dataSources.ToArray());
HttpContent postContent = new StringContent(JsonConvert.SerializeObject(dataSources.ToArray()), Encoding.UTF8, "application/json");
var response = clientWebAPI.PostAsync(<method / procedure to call>, postContent);
if (!response.Result.IsSuccessStatusCode)
queryResultDataWebAPI = string.Empty;
queryResultDataWebAPI = response.Result.Content.ReadAsStringAsync().Result;
}
private HttpClient CreateClient(string dynamicsURI, string AccessToken)
{
var client = new HttpClient();
client.BaseAddress = new Uri(dynamicsURI + "/api/services/");
client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", AccessToken);
client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json"));
client.DefaultRequestHeaders.Add("ZUMO-API-VERSION", "2.0.0");
client.Timeout = TimeSpan.FromMinutes(30);
return client;
}
Does the call need to be using XML instead of JSON since SOAP is XML based and we have not changed the D365 system?
What piece of am I missing in this puzzle?
Does anybody know for certain if SOAP is being removed from D365 F&O? I'm seeing conflicting responses on web sites.
any assistance is appreciated.
Thanks
Duane.