Skip to content

Error while creating power outlet via API #7864

@VictorPavlushin

Description

@VictorPavlushin

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

Metadata

Metadata

Assignees

Labels

status: acceptedThis issue has been accepted for implementationtype: bugA confirmed report of unexpected behavior in the application

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions