1

I'm designing a simple versioned RESTful API. The version will be specified as part of the media type in the Accept header. I wonder what are the proper HTTP status codes for these cases:

  • version not yet supported, e.g.

    Accept: application/json; version=999.0
    
  • version no longer supported

    Accept: application/json; version=0.1
    
planetp
  • 14,248
  • 20
  • 86
  • 160

2 Answers2

1

Seems you should use 406 Not Acceptable for both cases.

406 Not Acceptable The resource identified by the request is only capable of generating response entities which have content characteristics not acceptable according to the accept headers sent in the request.

carcinogen75
  • 51
  • 1
  • 4
0

According to ASP.NET repo, that would either be 400 or 405, depending on the situation:

Status Code Error Code Summary
400 ApiVersionUnspecified An API version is required, but was not specified
400, 405 UnsupportedApiVersion The specified API version is not supported
400 InvalidApiVersion An API version was specified, but it is invalid
400 AmbiguousApiVersion An API version was specified multiple times with different values

For more info see: https://github.com/dotnet/aspnet-api-versioning/wiki/Error-Responses

Ohad Schneider
  • 36,600
  • 15
  • 168
  • 198