howto create a mac address with python script #20101
-
We tested with PUT and POST method with same json parameters. The request is successfull over the webinterface (https://netbox/api/schema/swagger-ui) Thus the following script is intended to create a new mac address: (Create Mac Address)
The result is: Error querying NetBox API: 400 Client Error: Bad Request for url: https://ip.add.re.ss/api/dcim/mac-addresses/?mac_address=FF%3AFF%3AFF%3A99%3A99%3A11&display=FF%3AFF%3AFF%3A99%3A99%3A11&assigned_object_type=dcim.interface&assigned_object_id=123&description=FF%3AFF%3AFF%3A99%3A99%3A11&comments=FF%3AFF%3AFF%3A99%3A99%3A11&tags=3 We were asked to create a discussion post as this is probably not a bug. See: #20094 Can you please help us understand whats wrong? We are willing to provide any additional informations necessary. Thanks in advance for your kind support. |
Beta Was this translation helpful? Give feedback.
Replies: 4 comments
-
One apparent problem is that |
Beta Was this translation helpful? Give feedback.
-
We also tried without setting display first. Same result. |
Beta Was this translation helpful? Give feedback.
-
I'd also recommend replacing |
Beta Was this translation helpful? Give feedback.
-
The problem was in the parameters of the url for post request the name of the json data is "json", for get requests "params" ex. response_mac = requests.post(f"{NETBOX_API_URL}dcim/mac-addresses/", headers=headers, json=json, verify=False) Thanks for quick and valuable support! |
Beta Was this translation helpful? Give feedback.
I'd also recommend replacing
params
withjson