Currently working on an implementation where an external API will be posting information to D365 FO. I've implemented something similar using a data contract in X and using this as the parameter for the service method.
using System.Net;
class NmbGtwTmsReceiver
{
//WHAT NEEDS TO BE INCLUDED IN THE PARAMETER HERE?
public HttpStatusCode processXMLPost()
{
return HttpStatusCode::OK;
}
}
But if D365 is receiving an XML, do I need to use a data contract? I tried using an external C# class as the parameter and tried posting a sample xml file to this endpoint and it returns a deserialization error. There is an issue with the parameter I am using.
{
"Message": "An exception occurred when deserializing the request - Exception occurred when parsing the request content - Unexpected character encountered while parsing value: <. Path '', line 0, position 0.",
"ExceptionType": "XppServicesDeserializationException",
"ActivityId": "86f94c34-622a-0003-c059-fa862a62d901"
}
The current behavior noticed from using JSON is that the parameter name in this method needs to be a field in the incoming JSON of the request. An example is this, when my function header is:
- "public HttpStatusCode processXMLPost(SampleDataContract _data) {}
Then inside the request being sent to this service function, the json needs to be:
If the above is what is needed, how would I be able to do this for XML data or is there a way to get the full request object as a parameter or a different type of parameter needed?