Group is required attribute on Contact object when using REST API #5626

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

Originally created by @rodvand on GitHub (Nov 7, 2021).

Originally assigned to: @jeremystretch on GitHub.

NetBox version

v3.1-beta1

Python version

3.8

Steps to Reproduce

curl -X POST \
-H "Authorization: Token TOKEN" \
-H "Content-Type: application/json" \
-H "Accept: application/json; indent=4" \
https://NETBOX/api/tenancy/contacts/ \
--data '{
    "name": "Martin"
}'

Expected Behavior

Contact is created.

Observed Behavior

{
    "group": [
        "This field is required."
    ]
}

In the API docs the group attribute is set as required, while it is not (at least visibly) required in the NetBox UI.

Adding "group": null to the curl command allows the contact to be created.

Originally created by @rodvand on GitHub (Nov 7, 2021). Originally assigned to: @jeremystretch on GitHub. ### NetBox version v3.1-beta1 ### Python version 3.8 ### Steps to Reproduce ``` curl -X POST \ -H "Authorization: Token TOKEN" \ -H "Content-Type: application/json" \ -H "Accept: application/json; indent=4" \ https://NETBOX/api/tenancy/contacts/ \ --data '{ "name": "Martin" }' ``` ### Expected Behavior Contact is created. ### Observed Behavior ``` { "group": [ "This field is required." ] } ``` In the API docs the group attribute is set as required, while it is not (at least visibly) required in the NetBox UI. Adding `"group": null` to the curl command allows the contact to be created.
adam added the type: bugstatus: acceptedbeta labels 2025-12-29 19:30:16 +01:00
adam closed this issue 2025-12-29 19:30:16 +01:00
Author
Owner

@jeremystretch commented on GitHub (Nov 8, 2021):

For anyone interested, this is a peculiar quirk of uniqueness validation within DRF. Because the group field is part of a uniqueness constraint, the serializer field must have a value for it (even if that value is null).

@jeremystretch commented on GitHub (Nov 8, 2021): For anyone interested, this is a peculiar quirk of uniqueness validation within DRF. Because the `group` field is part of a uniqueness constraint, the serializer field _must_ have a value for it (even if that value is null).
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/netbox#5626