1

Closed

wrong content-type for 422 validation failure

description

Seems to be set to text/html instead of application/json;profile=".../error"

a stack trace from fiddler:

POST http://localhost:6565/services/sdm.restserver.RestApi.MeansAssessmentRestApi/actions/CreateMeansAssessment/invoke HTTP/1.1
Accept: application/json, application/xml, text/json, text/x-json, text/javascript, text/xml, application/json
User-Agent: RestSharp 104.1.0.0
Content-Type: application/json
Host: localhost:6565
Content-Length: 135
Accept-Encoding: gzip, deflate

{"Context":{"value":{"href":"http://192.168.57.1:8888/objects/CAR/CAR%7C15"}},"Date of Effect":{"value":"2013-02-21T12:05:42.4677636"}}


generated:

HTTP/1.1 422 Unprocessable Entity
Server: ASP.NET Development Server/11.0.0.0
Date: Thu, 21 Feb 2013 12:05:47 GMT
X-AspNet-Version: 4.0.30319
Pragma: no-cache
Warning: 199 RestfulObjects "Context is not valid"
Warning: 199 RestfulObjects "Context is not valid"
Cache-Control: no-cache
Expires: Thu, 21 Feb 2013 12:05:47 GMT
Content-Type: text/html
Content-Length: 214
Connection: Close

{"Context":{"value":{"href":"http://192.168.57.1:8888/objects/CAR/CAR%7C15"},"invalidReason":"Context is not valid"},"Date of Effect":{"value":"2013-02-21T12:05:42.4677636Z","invalidReason":"Context is not valid"}}
Closed May 9, 2013 at 3:30 PM by RichardPawson

comments

scascarini wrote Feb 21, 2013 at 3:40 PM

Happy to implement - however the spec does not define any Content-Type header for a 422 error. I assume web-api is just defaulting to text/html as it's not being explicitly set.