Trying to update Interfaces via API but get error. #12821
-
Hi everyone, I'm trying to update interfaces for devices via API from PHP, When i try to update the mac-address i get an error from the API: 400 Bad Request` response: {"mac_address":["Invalid MAC address format: unknown"]} I'm using this url: https://xxxxxxxxx/api/dcim/interfaces/1725/ and trying to post the following Json: { I have tried the mac-address in several ways, with and without :, but are still getting an error. When i try the same json via swagger it works (getting response 200). I dont know what i'm doing wrong! Br |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 2 replies
-
It sounds like a problem with your PHP code then - can you post the code which reproduces the problem? You could also try tcpdump on the Netbox server ( |
Beta Was this translation helpful? Give feedback.
-
This is the PHP-code that makes the call:
The code that the dd command produces is: "{"device":"58","name":"Bridge-Aggregation1","enabled":true,"label":"Some text","speed":"20000000","mac_address":"AABBCCDDEEFF"}" // app/Models/Netbox.php:468 |
Beta Was this translation helpful? Give feedback.
The things that strike me immediately are:
"device": "58"
instead of"device": 58
."id": <interface-id>
rather than attempting to identify it by a device+name combinationTherefore, although the error message complains about the mac_address, it might actually be something else that's wrong with the request and the error message is a red herring.
You definitely want to compare what your working swagger client sends, with what you're sending from PHP (using the tcpdump command I gave before)