Efficiently create device with IP address via API #14643
-
I'm trying to build a script to help add batches of devices into Netbox when we commission a new room. This process typically involves adding 10-15 new devices, each with a power port connection, ethernet switch connection, and primary IP. I'm not seeing a way to create the device with a single API call; is this possible? The API schema docs show that The interface is created automatically because it's part of the Device Type, so I was hoping this could all be handled in a single API call. The alternative I found is convoluted and takes several API calls:
Then I would have to do a similar process to connect the power cable and ethernet cables. |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 1 reply
-
You can only attach an IP address as primary if it exists on one of the interfaces for the device. So, your API calls look correct |
Beta Was this translation helpful? Give feedback.
-
How did you get your script to automatically make new devices? I wrote a scrip to scan the network make the IPs on the netbox UI and its supposed to make new devices to go with the IPs but I keep getting this error. |
Beta Was this translation helpful? Give feedback.
You can only attach an IP address as primary if it exists on one of the interfaces for the device. So, your API calls look correct