Under what circumstances is a 202 returned

Topics: Web Api
Oct 19, 2011 at 1:41 PM

We are seeing a case where a 202 (verse 200) is being returned when sending the similar requests. These requests have the same headers except for the Authorization. We are using POST and the body is empty. 

I found a couple references to '202 - Accepted' in the Wcf Web Aapi code and was wondering under what conditions would that be returned.  The most obvious condition would be Asynchronous calls to the service. We are not doing asynchronous calls though.

Thanks

Oct 19, 2011 at 6:44 PM

We had a convention which was mostly a leftover from the old HTTP stack that if you return null from an operation then it results in a 202 response. However, we have changed that so that you now instead just get an empty 200 response. I sounds like this change was after the preview 5 bits were finalized but I don’t remember exactly.

The other place that may generate a 202 response is if you sit as a DelegatingChannel and return null instead of an HttpResponseMessage as the result of the Task<HttpResponseMessage> SendAsync overload. We will likely get rid of this too as it is much simpler to set the status code explicitly instead of implicit rules.

For now, I would check that you don’t return null in places.

Henrik

From: ssuing8825 [email removed]
Sent: Wednesday, October 19, 2011 5:41 AM
To: Henrik Frystyk Nielsen
Subject: Under what circumstances is a 202 returned [wcf:276433]

From: ssuing8825

We are seeing a case where a 202 (verse 200) is being returned when sending the similar requests. These requests have the same headers except for the Authorization. We are using POST and the body is empty.

I found a couple references to '202 - Accepted' in the Wcf Web Aapi code and was wondering under what conditions would that be returned. The most obvious condition would be Asynchronous calls to the service. We are not doing asynchronous calls though.

Thanks