-
Notifications
You must be signed in to change notification settings - Fork 2.9k
Closed
Copy link
Labels
severity: lowDoes not significantly disrupt application functionality, or a workaround is availableDoes not significantly disrupt application functionality, or a workaround is availablestatus: acceptedThis issue has been accepted for implementationThis issue has been accepted for implementationtype: bugA confirmed report of unexpected behavior in the applicationA confirmed report of unexpected behavior in the application
Milestone
Description
Deployment Type
Self-hosted
NetBox Version
v4.3.5
Python Version
3.10
Steps to Reproduce
- Make a REST API
GET
request without specifying a content type:
curl -v -X GET \
-H "Authorization: Token $TOKEN" \
-H "Accept: application/json; indent=4" \
http://netbox:8000/api/status/
- Inspect the response headers.
Expected Behavior
The response should include an API-Version
header indicating the NetBox version. This can be verified by re-sending the above request with a Content-Type
header:
curl -v -X GET \
-H "Authorization: Token $TOKEN" \
-H "Content-Type: application/json" \
-H "Accept: application/json; indent=4" \
http://netbox:8000/api/status/
Observed Behavior
The API-Version
header is missing from the response.
The is_api_request()
utility function is intended to return True for any request which qualifies as consuming the REST API. However, this happens only if the request has specified a Content-Type
of application/json
:
netbox/netbox/utilities/api.py
Lines 55 to 60 in c7b6866
def is_api_request(request): | |
""" | |
Return True of the request is being made via the REST API. | |
""" | |
api_path = reverse('api-root') | |
return request.path_info.startswith(api_path) and request.content_type == HTTP_CONTENT_TYPE_JSON |
The content type should not be a condition of qualifying as an API request.
Metadata
Metadata
Assignees
Labels
severity: lowDoes not significantly disrupt application functionality, or a workaround is availableDoes not significantly disrupt application functionality, or a workaround is availablestatus: acceptedThis issue has been accepted for implementationThis issue has been accepted for implementationtype: bugA confirmed report of unexpected behavior in the applicationA confirmed report of unexpected behavior in the application