PUT / POST Request to API #5915
Replies: 2 comments 3 replies
-
This was fun :-) The first things I spotted (which are not the main problem):
I first replicated your problem like this:
What I found was that the Then I replicated with your python code, and I found the same as you. I did a tcpdump, and I was able to see the headers were not being set. Not only that, but there was no data in the body!
But tcpdump also showed what the real problem was:
You had forgotten the trailing slash from the URL. Netbox issued a redirect, and requests followed the redirect; but when it re-issued the PATCH to the new URL, the body was empty and the headers forgotten. This seems like a bug in requests to me. Anyway, here is the fixed version:
I suggest it might be better to use pynetbox instead of raw requests going forward, as it wraps all this nicely for you. |
Beta Was this translation helpful? Give feedback.
-
I created also a Wireshark dump to verify PUT request Full Wireshark dump. |
Beta Was this translation helpful? Give feedback.
-
Hi,
I have some problems with modifying the existing objects in Netbox with PUT or PATCH via API.
With the PATCH command I get always a result of 200, I see in the log there was a change on object but no value was updated. With the PUT statement I get the error code 400 with the message.
I tried 2.10.3 + the latest 2.10.5 version.
Here is my python sample
Any ideas?
Beta Was this translation helpful? Give feedback.
All reactions