Error while creating power outlet via API #5684

Closed
opened 2025-12-29 19:31:28 +01:00 by adam · 1 comment
Owner

Originally created by @VictorPavlushin on GitHub (Nov 18, 2021).

Originally assigned to: @jeremystretch on GitHub.

NetBox version

v3.0.8

Python version

3.9

Steps to Reproduce

If, when creating a power outlet via the API, pass a zero port power value ("power_port": null), an error is generated: {"power_port": ["This field may not be null."]}.
The documentation says:

power_port integer
          title: Power port
          x-nullable: true
# curl -X POST http://localhost:8001/api/dcim/power-outlets/ \ 
    -H 'Content-Type: application/json' \
    -H "Authorization: TOKEN 0000000000000000000000000000000000000" \
    -d '{"description": "", "device": 6660, "feed_leg": null, "label": "", "mark_connected": false, "name": "C13-1", "power_port": null, "tags": [], "type": "iec-60320-c13"}'
{"power_port":["This field may not be null."]}(venv)

# curl -X POST http://localhost:8001/api/dcim/power-outlets/  \
    -H 'Content-Type: application/json'  \
    -H "Authorization: TOKEN 0000000000000000000000000000000000000" \
    -d '{"description": "", "device": 6660, "feed_leg": null, "label": "", "mark_connected": false, "name": "C13-1", "tags": [], "type": "iec-60320-c13"}'
{"id":9160,"url":"http://localhost:8001/api/dcim/power-outlets/9160/","display":"C13-1","device":{"id":6660,"url":"http://localhost:8001/api/dcim/devices/6660/","display":"DEVICENAME","name":"DEVICENAME"},"name":"C13-1","label":"","type":{"value":"iec-60320-c13","label":"C13"},"power_port":null,"feed_leg":null,"description":"","mark_connected":false,"cable":null,"cable_peer":null,"cable_peer_type":null,"connected_endpoint":null,"connected_endpoint_type":null,"connected_endpoint_reachable":null,"tags":[],"custom_fields":{},"created":"2021-11-18","last_updated":"2021-11-18T12:24:21.206422+07:00","_occupied":false}

Expected Behavior

Successful device creation

Observed Behavior

Got out the error

Originally created by @VictorPavlushin on GitHub (Nov 18, 2021). Originally assigned to: @jeremystretch on GitHub. ### NetBox version v3.0.8 ### Python version 3.9 ### Steps to Reproduce If, when creating a power outlet via the API, pass a zero port power value (`"power_port": null`), an error is generated: `{"power_port": ["This field may not be null."]}`. The documentation says: ``` power_port integer title: Power port x-nullable: true ``` ```bash # curl -X POST http://localhost:8001/api/dcim/power-outlets/ \ -H 'Content-Type: application/json' \ -H "Authorization: TOKEN 0000000000000000000000000000000000000" \ -d '{"description": "", "device": 6660, "feed_leg": null, "label": "", "mark_connected": false, "name": "C13-1", "power_port": null, "tags": [], "type": "iec-60320-c13"}' {"power_port":["This field may not be null."]}(venv) # curl -X POST http://localhost:8001/api/dcim/power-outlets/ \ -H 'Content-Type: application/json' \ -H "Authorization: TOKEN 0000000000000000000000000000000000000" \ -d '{"description": "", "device": 6660, "feed_leg": null, "label": "", "mark_connected": false, "name": "C13-1", "tags": [], "type": "iec-60320-c13"}' {"id":9160,"url":"http://localhost:8001/api/dcim/power-outlets/9160/","display":"C13-1","device":{"id":6660,"url":"http://localhost:8001/api/dcim/devices/6660/","display":"DEVICENAME","name":"DEVICENAME"},"name":"C13-1","label":"","type":{"value":"iec-60320-c13","label":"C13"},"power_port":null,"feed_leg":null,"description":"","mark_connected":false,"cable":null,"cable_peer":null,"cable_peer_type":null,"connected_endpoint":null,"connected_endpoint_type":null,"connected_endpoint_reachable":null,"tags":[],"custom_fields":{},"created":"2021-11-18","last_updated":"2021-11-18T12:24:21.206422+07:00","_occupied":false} ``` ### Expected Behavior Successful device creation ### Observed Behavior Got out the error
adam added the type: bugstatus: accepted labels 2025-12-29 19:31:28 +01:00
adam closed this issue 2025-12-29 19:31:28 +01:00
Author
Owner

@VictorPavlushin commented on GitHub (Nov 18, 2021):

The same thing happens when you try to update the bullets with the PUT and PATCH methods /api/dcim/power-ports/{id} data: {"feed_leg": null, "power_port": null}

@VictorPavlushin commented on GitHub (Nov 18, 2021): The same thing happens when you try to update the bullets with the PUT and PATCH methods `/api/dcim/power-ports/{id}` data: `{"feed_leg": null, "power_port": null}`
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/netbox#5684