Add user to group via API #6858

Closed
opened 2025-12-29 19:46:07 +01:00 by adam · 3 comments
Owner

Originally created by @mazhead on GitHub (Aug 23, 2022).

NetBox version

v3.1.5

Python version

3.9

Steps to Reproduce

  1. Create group via users/groups (POST)
  2. Try to add user via users/users/{id} (PATCH) with only json body:
{
  "groups": [
    1
  ]
}

Get error:

{
  "error": "'password'",
  "exception": "KeyError",
  "netbox_version": "3.1.5",
  "python_version": "3.9.2"
}

Expected Behavior

Add user to a group without knowing the user password

Observed Behavior

{
  "error": "'password'",
  "exception": "KeyError",
  "netbox_version": "3.1.5",
  "python_version": "3.9.2"
}
Originally created by @mazhead on GitHub (Aug 23, 2022). ### NetBox version v3.1.5 ### Python version 3.9 ### Steps to Reproduce 1. Create group via users/groups (POST) 2. Try to add user via users/users/{id} (PATCH) with only json body: ``` { "groups": [ 1 ] } ``` Get error: ``` { "error": "'password'", "exception": "KeyError", "netbox_version": "3.1.5", "python_version": "3.9.2" } ``` ### Expected Behavior Add user to a group without knowing the user password ### Observed Behavior ``` { "error": "'password'", "exception": "KeyError", "netbox_version": "3.1.5", "python_version": "3.9.2" } ```
adam added the type: bug label 2025-12-29 19:46:07 +01:00
adam closed this issue 2025-12-29 19:46:07 +01:00
Author
Owner

@DanSheps commented on GitHub (Aug 23, 2022):

Thank you for opening a bug report. I was unable to reproduce the reported behavior on NetBox v3.3.0. Please re-confirm the reported behavior on the current stable release and adjust your post above as necessary. Remember to provide detailed steps that someone else can follow using a clean installation of NetBox to reproduce the issue. Remember to include the steps taken to create any initial objects or other data.

@DanSheps commented on GitHub (Aug 23, 2022): Thank you for opening a bug report. I was unable to reproduce the reported behavior on NetBox v3.3.0. Please re-confirm the reported behavior on the current stable release and adjust your post above as necessary. Remember to provide detailed steps that someone else can follow using a clean installation of NetBox to reproduce the issue. Remember to include the steps taken to create any initial objects or other data.
Author
Owner

@jeremystretch commented on GitHub (Aug 23, 2022):

I can confirm that this works as expected on v3.3.0:

$ curl -X PATCH \
> -H "Authorization: Token $TOKEN" \
> -H "Content-Type: application/json" \
> -H "Accept: application/json; indent=4" \
> http://netbox:8000/api/users/users/2/ \
> --data '{"groups": [2]}'
{
    "id": 2,
    "url": "http://netbox:8000/api/users/users/2/",
    "display": "alice",
    "username": "alice",
    "first_name": "",
    "last_name": "",
    "email": "",
    "is_staff": false,
    "is_active": true,
    "date_joined": "2021-12-30T15:51:08Z",
    "groups": [
        {
            "id": 2,
            "url": "http://netbox:8000/api/users/groups/2/",
            "display": "Foo",
            "name": "Foo"
        }
    ]
}
@jeremystretch commented on GitHub (Aug 23, 2022): I can confirm that this works as expected on v3.3.0: ``` $ curl -X PATCH \ > -H "Authorization: Token $TOKEN" \ > -H "Content-Type: application/json" \ > -H "Accept: application/json; indent=4" \ > http://netbox:8000/api/users/users/2/ \ > --data '{"groups": [2]}' { "id": 2, "url": "http://netbox:8000/api/users/users/2/", "display": "alice", "username": "alice", "first_name": "", "last_name": "", "email": "", "is_staff": false, "is_active": true, "date_joined": "2021-12-30T15:51:08Z", "groups": [ { "id": 2, "url": "http://netbox:8000/api/users/groups/2/", "display": "Foo", "name": "Foo" } ] } ```
Author
Owner

@mazhead commented on GitHub (Aug 23, 2022):

thanks for quick turnaround, checked latest 3.1 (3.1.11 as I can see) and the bug is not present there.

@mazhead commented on GitHub (Aug 23, 2022): thanks for quick turnaround, checked latest 3.1 (3.1.11 as I can see) and the bug is not present there.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/netbox#6858