I have the following method on a wcf web service.
[OperationContract]
[WebInvoke(Method = "POST",
ResponseFormat = WebMessageFormat.Json,
RequestFormat = WebMessageFormat.Json,
BodyStyle = WebMessageBodyStyle.WrappedRequest)]
public void UpdateAnalysisParameters(string parameterSets)
{
//....
}
But I am having trouble posting data to it. I am using the following jquery Ajax call.
$.ajax({
url: "/ATOMWebService.svc/UpdateAnalysisParameters",
dataType: "json",
type: "POST",
data: JSON.stringify({ parameterSets: "Dave" })
});
But the web service is responding with "The incoming message has an unexpected message format 'Raw'. The expected message formats for the operation are 'Xml', 'Json'."
How can I post json data to this web service?
Try specifying the content type in your ajax request:
Setting the dataType only gives a hint to jquery about how to handle the received response.