Hi,
I have a problem about WCF web service POST operation contract.
If I send my json string like this(bare), I get bad request(400) error. If I wrapped this json string, then empty object will came to method.
{"WorkCommandNumber":"F999/1","BLPProductCode":"F999","ReceivedOrderNumber":16,"GroupNumber":1,"WorkCommandOpenDate":"2017-12-04T23:00:00+02:00","RevisionCode":"R0","DeliveryLocation":"LOCATION XYZ","DueDate":"2018-01-09T00:00:00+02:00","ShippingDate":null,"Notes":"Test Note","WorkCommandDocuments":[],"WorkCommandProblems":[],"WorkCommandProductionConsignments":[],"WorkCommandProductionProcesses":[{"ID":20,"ProductionProcessCode":"APPROVAL","CompanyCode":"BLP","WorkCommandNumber":"F999/1"}],"WorkCommandProductions":{"WorkCommandNumber":"F999/1","ProductionMaterial":"PLASTIC","ProductionStartDate":"2017-12-04T00:00:00+02:00","ProductionFinishDate":null,"MoldKnifeStockCode":null},"WorkCommandProductionTools":[],"WorkCommandSubProducts":[]}
Can you help me about this issue?
Thank you.
EDIT: The issue was .NET Json Serializer serializes the Date's ISO format.("2017-12-04T00:00:00+02:00")
But the WCF service can't convert this Date format, and it gets null or empty object.
When I change the Date format form ISO formatting to Windows formatting the problem solved.
What I have tried:
My Operation Contract;
[OperationContract]
[WebInvoke(Method = "POST", ResponseFormat = WebMessageFormat.Json, RequestFormat = WebMessageFormat.Json, BodyStyle = WebMessageBodyStyle.Bare, UriTemplate = "/UpdateWorkCommand")]
string UpdateWorkCommand(WorkCommand WorkCommandToUpdate);
Tryings;
1- Set BodyStyle = WebMessageBodyStyle.Bare and send bare json string. (400 Bad Request)
2- Set BodyStyle = WebMessageBodyStyle.Bare and send wrapped json string. (Empty object comes(not null))
3- Set BodyStyle = WebMessageBodyStyle.Wrapped and send wrapped json string.(400 Bad Request)
4- Set BodyStyle = WebMessageBodyStyle.Wrapped and send bare json string.(Null object comes)
public string UpdateWorkCommand(WorkCommand WorkCommandToUpdate)
{
}
I'm calling this service method with JSON string using Postman.
P.S: I set the header's content-type to "application-json"