netbox
netbox copied to clipboard
Can't place multiple devices in rack with non-racked device (using API)
Deployment Type
Self-hosted
Triage priority
This is preventing me from using NetBox
NetBox Version
v4.1.4
Python Version
3.12
Steps to Reproduce
- Create site
- Create rack in the site (for example with id = 1)
- Create first non-racked device in rack
- Create second device
- Try placing the the device in the rack as non-racked device via API
Important: I can only reproduce the problem using the REST API.
API Calls
# Create first device, non-racked in the rack (remember the id, ensure there are no devices non-racked before)
curl -X POST -H "authorization: Token TOKEN" -H 'Content-Type: application/json' -d '{"device_type":116,"role":25,"site":1,"rack":168}' https://netbox.example.org/api/dcim/devices/ | jq .id
# Create second device, floating around in the site
curl -X POST -H "authorization: Token TOKEN" -H 'Content-Type: application/json' -d '{"device_type":116,"role":25,"site":1}' https://netbox.example.org/api/dcim/devices/ | jq . | less
# Try moving the device to the rack of the first device non-racked (fails)
curl -X PATCH -H "authorization: Token TOKEN" -H 'Content-Type: application/json' -d '{"rack":168}' https://netbox.example.org/api/dcim/devices/$ID_FROM_THE_FIRST_COMMAND/ | jq . | less
# Run first command again, creating another device, doesn't fail strangely
curl -X POST -H "authorization: Token TOKEN" -H 'Content-Type: application/json' -d '{"device_type":116,"role":25,"site":1,"rack":168}' https://netbox.example.org/api/dcim/devices/ | jq .id
Expected Behavior
Device should be placed in the rack as non-racked.
Observed Behavior
HTTP 400 Error Code
{"non_field_errors": ["The fields rack, position, face must make a unique set."]}