I have a simple REST web service in WCF that is declared as follows:
[WebInvoke(Method = "PUT",UriTemplate = "comptatge/add",RequestFormat = WebMessageFormat.Json,ResponseFormat = WebMessageFormat.Json)]
public void GravaComptatge(MyDataContract contract)
{
...
}
where MyDataContract
is a class with simple properties.
Now I send a put Request using fiddler to see if it works OK. In the body I send JSON with the same properties as MyDataContract
but it's not working. I get a 400 Bad Request HTTP error. What am I doing wrong here? The service is hosted in a MVC app using ServiceRoute. Other GET services work OK.
这发生在我之前,并在请求标头中添加Content-Type: application/json
是解决方案。
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.