netbox-community / pynetbox

Python API client library for Netbox.
Apache License 2.0
567 stars 168 forks source link

Fixes: Enforce application/json content type #512

Closed Simkimdm closed 1 year ago

Simkimdm commented 1 year ago

With Version 3.3 the Content Type: application/json is enforced by netbox. https://github.com/netbox-community/netbox/commit/bfbf97aec9119539f7f42cf16f52d0ca8203ba60 / https://www.django-rest-framework.org/api-guide/parsers/

It takes long to find the Problem why i am getting a 403 Error just while Post requests. I finally get it fixed by removing the ";" in all '"Content-Type": "application/json;"'. Also in all API examples its always called without the ending ";". docs/integrations/rest-api.md / https://github.com/netbox-community/netbox/blob/d2fe59ae8f9c34c1f8a7d51c0d113348d7bed937/netbox/utilities/api.py#L52

Hope this is request is okay?

markkuleinio commented 1 year ago

I'm unable to reproduce the 403 error but I'm still in favor of removing the extra semicolons.

>>> tag = nb.extras.tags.create(name="TestTag", slug="testtag")
>>> tag
TestTag
>>> pynetbox.__version__
'6.6.2'
>>> nb.status()["netbox-version"]
'3.3.7'
>>>

access.log:

172.16.10.10 - - [07/Nov/2022:11:00:34 +0200] "POST /api/extras/tags/ HTTP/1.1" 201 251 "-" "python-requests/2.28.0"

https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Content-Type says that the semicolon is used for separating the charset.

abhi1693 commented 1 year ago

This will be superseded by #547 when its merged.