Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Version Identification in API #1223

Closed
DerekTBrown opened this issue May 24, 2017 · 1 comment
Closed

Version Identification in API #1223

DerekTBrown opened this issue May 24, 2017 · 1 comment

Comments

@DerekTBrown
Copy link

Would it be possible to include the API Version String in the API Endpoint (/api/), so that REST clients can validate that the version is correct?

@DerekTBrown DerekTBrown changed the title [Feature Request] Version Identification in API [Feature] Version Identification in API May 24, 2017
@jeremystretch
Copy link
Member

NetBox uses request headers rather than URL parameters for versioning. The API version is indicated in the API-Version response header:

* HTTP 1.0, assume close after body
< HTTP/1.0 200 OK
< Date: Wed, 24 May 2017 18:25:01 GMT
< Server: WSGIServer/0.1 Python/2.7.6
< Content-Length: 549
< Vary: Accept, Cookie
< Allow: GET, PUT, PATCH, DELETE, OPTIONS
< API-Version: 2.0
< X-Frame-Options: SAMEORIGIN
< Content-Type: application/json

Requests for a version other than the current version will be rejected:

$ curl -v -H "Accept: application/json; version=1.0" http://localhost:8000/api/
* Hostname was NOT found in DNS cache
*   Trying 127.0.0.1...
* Connected to localhost (127.0.0.1) port 8000 (#0)
> GET /api/ HTTP/1.1
> User-Agent: curl/7.35.0
> Host: localhost:8000
> Accept: application/json; version=1.0
> 
* HTTP 1.0, assume close after body
< HTTP/1.0 406 Not Acceptable
< Date: Wed, 24 May 2017 18:29:53 GMT
< Server: WSGIServer/0.1 Python/2.7.6
< Content-Length: 50
< Vary: Accept
< Allow: GET, HEAD, OPTIONS
< API-Version: 2.0
< X-Frame-Options: SAMEORIGIN
< Content-Type: application/json
< 
* Closing connection 0

Granted, this needs to be added to the API documentation.

@jeremystretch jeremystretch changed the title [Feature] Version Identification in API Version Identification in API May 25, 2017
@lock lock bot locked as resolved and limited conversation to collaborators Jan 18, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants