As of the 5.1 update you've introduced a serious issue in to Request.CreateResponse.
If you return Request.CreateResponse(HttpStatusCode.OK) (or Accepted or any other success code) and the jquery ajax call is setup something like this:
```
$.ajax({
type: "PUT",
url: url,
dataType: "json",
data: value == null ? null : JSON.stringify(value),
contentType: "application/json; charset=utf-8",
```
even though Request.CreateResponse is returning OK it will fail.
And before you say don't set the dataType to json if it isn't expecting a json response, lots of us have a lot of code that is generic for calling web api, and this isn't feesible because it would then have to know if it should be getting a value response back or not.
Web API used to return "no content" in the headers in the above CreateResponse example with no value, as it should. It now is not.
I would classify this as a massively breaking change that needs to be fixed ASAP and a public stable point release produced to fix it.
Comments: Thanks for the details. I tried to repro your scenario and the issue looks to be with how JQuery behaves. For example, you can take a look at the following traces of request and responses from Fiddler tool: __Request__: ``` PUT http://kirandesktop/WebApplication284/api/values/1 HTTP/1.1 Accept: application/json, text/javascript, */*; q=0.01 X-Requested-With: XMLHttpRequest Content-Type: application/json; charset=UTF-8 Host: kirandesktop Content-Length: 7 "Hello" ``` __Response__: ``` HTTP/1.1 202 Accepted Cache-Control: no-cache Pragma: no-cache Expires: -1 Server: Microsoft-IIS/8.5 X-AspNet-Version: 4.0.30319 X-Powered-By: ASP.NET Date: Mon, 03 Feb 2014 23:16:01 GMT Content-Length: 0 ``` I see the that the JQuery fail function callback is being invoked even though the statuscode is set actually a sucess. Following forum question user also had a similar problem and this is not related to Web API. http://stackoverflow.com/questions/15415498/jquery-ajax-calls-error-callback-on-202-response-shouldnt-that-be-a-success-cal As the user suggested in the forum, you can do the following to see that Web API infact works as expected. ``` .statusCode({ 200: function () { alert("200 returned") }, 202: function () { alert("202 returned") }, 204: function () { alert("204 returned") }, 400: function () { alert("400 returned") }, 404: function () { alert("404 returned") } }); ``` If you still think that this is an issue with Web API. Please send us the request and response traces.
If you return Request.CreateResponse(HttpStatusCode.OK) (or Accepted or any other success code) and the jquery ajax call is setup something like this:
```
$.ajax({
type: "PUT",
url: url,
dataType: "json",
data: value == null ? null : JSON.stringify(value),
contentType: "application/json; charset=utf-8",
```
even though Request.CreateResponse is returning OK it will fail.
And before you say don't set the dataType to json if it isn't expecting a json response, lots of us have a lot of code that is generic for calling web api, and this isn't feesible because it would then have to know if it should be getting a value response back or not.
Web API used to return "no content" in the headers in the above CreateResponse example with no value, as it should. It now is not.
I would classify this as a massively breaking change that needs to be fixed ASAP and a public stable point release produced to fix it.
Comments: Thanks for the details. I tried to repro your scenario and the issue looks to be with how JQuery behaves. For example, you can take a look at the following traces of request and responses from Fiddler tool: __Request__: ``` PUT http://kirandesktop/WebApplication284/api/values/1 HTTP/1.1 Accept: application/json, text/javascript, */*; q=0.01 X-Requested-With: XMLHttpRequest Content-Type: application/json; charset=UTF-8 Host: kirandesktop Content-Length: 7 "Hello" ``` __Response__: ``` HTTP/1.1 202 Accepted Cache-Control: no-cache Pragma: no-cache Expires: -1 Server: Microsoft-IIS/8.5 X-AspNet-Version: 4.0.30319 X-Powered-By: ASP.NET Date: Mon, 03 Feb 2014 23:16:01 GMT Content-Length: 0 ``` I see the that the JQuery fail function callback is being invoked even though the statuscode is set actually a sucess. Following forum question user also had a similar problem and this is not related to Web API. http://stackoverflow.com/questions/15415498/jquery-ajax-calls-error-callback-on-202-response-shouldnt-that-be-a-success-cal As the user suggested in the forum, you can do the following to see that Web API infact works as expected. ``` .statusCode({ 200: function () { alert("200 returned") }, 202: function () { alert("202 returned") }, 204: function () { alert("204 returned") }, 400: function () { alert("400 returned") }, 404: function () { alert("404 returned") } }); ``` If you still think that this is an issue with Web API. Please send us the request and response traces.