# Error adding user to group via API

**URL:** <https://devforum.okta.com/t/error-adding-user-to-group-via-api/23378>\
**Category:** Questions\
**Created:** [February 16, 2023, 9:58pm UTC](https://devforum.okta.com/t/error-adding-user-to-group-via-api/23378 "2023-02-16T21:58:54Z")\
**Posts on this page:** 19\
**Page:** 1

<div class="post-metadata">

**Author:** ![jason.whisnant](https://avatars.discourse-cdn.com/v4/letter/j/50afbb/32.png) [@jason.whisnant](https://devforum.okta.com/u/jason.whisnant)\
**Post date:** [February 16, 2023, 9:58pm UTC](https://devforum.okta.com/t/error-adding-user-to-group-via-api/23378/1 "2023-02-16T21:58:54Z")

</div>

Hello,

I’m attempting to add users to a group via API. I got no results from my python script. When I test in Postman, I receive the following:

```auto
{
    "errorCode": "E0000022",
    "errorSummary": "The endpoint does not support the provided HTTP method",
    "errorLink": "E0000022",
    "errorId": "oaeru5O9-k_SxGkoQxjxwx26w",
    "errorCauses": []
}

```

Call in postman is {{url}}/api/v1/groups/{{groupId}}/users/{{userId}}

---

<div class="post-metadata">

**Author:** ![andrea](https://sea1.discourse-cdn.com/oktadev/user_avatar/devforum.okta.com/andrea/32/2172_2.png) [@andrea](https://devforum.okta.com/u/andrea)\
**Post date:** [February 16, 2023, 10:08pm UTC](https://devforum.okta.com/t/error-adding-user-to-group-via-api/23378/2 "2023-02-16T22:08:25Z")

</div>

Are you doing a PUT as per [our API docs](https://developer.okta.com/docs/reference/api/groups/#add-user-to-group)?

---

<div class="post-metadata">

**Author:** ![jason.whisnant](https://avatars.discourse-cdn.com/v4/letter/j/50afbb/32.png) [@jason.whisnant](https://devforum.okta.com/u/jason.whisnant)\
**Post date:** [February 16, 2023, 10:12pm UTC](https://devforum.okta.com/t/error-adding-user-to-group-via-api/23378/3 "2023-02-16T22:12:30Z")

</div>

Yes I am.

 ![image](https://global.discourse-cdn.com/oktadev/original/2X/f/fcd5bfbd2a316691be0e879c20f7bf67b869037a.png)

---

<div class="post-metadata">

**Author:** ![andrea](https://sea1.discourse-cdn.com/oktadev/user_avatar/devforum.okta.com/andrea/32/2172_2.png) [@andrea](https://devforum.okta.com/u/andrea)\
**Post date:** [February 16, 2023, 10:19pm UTC](https://devforum.okta.com/t/error-adding-user-to-group-via-api/23378/4 "2023-02-16T22:19:30Z")

</div>

Can you remove those `'` quotes and retry?

---

<div class="post-metadata">

**Author:** ![jason.whisnant](https://avatars.discourse-cdn.com/v4/letter/j/50afbb/32.png) [@jason.whisnant](https://devforum.okta.com/u/jason.whisnant)\
**Post date:** [February 16, 2023, 10:31pm UTC](https://devforum.okta.com/t/error-adding-user-to-group-via-api/23378/5 "2023-02-16T22:31:39Z")

</div>

Error is the same:

```auto
{
    "errorCode": "E0000022",
    "errorSummary": "The endpoint does not support the provided HTTP method",
    "errorLink": "E0000022",
    "errorId": "oaeWeFzpcZERJ-X3u-0bv2Z2w",
    "errorCauses": []
}

```

I also checked the {{groupId}} collection variable and removed the quotes from it. Request returned the same result as above.

---

<div class="post-metadata">

**Author:** ![andrea](https://sea1.discourse-cdn.com/oktadev/user_avatar/devforum.okta.com/andrea/32/2172_2.png) [@andrea](https://devforum.okta.com/u/andrea)\
**Post date:** [February 17, 2023, 12:07am UTC](https://devforum.okta.com/t/error-adding-user-to-group-via-api/23378/6 "2023-02-17T00:07:07Z")

</div>

Hmm… What type of group is this? Is it a local Okta group (created on the Okta side) or is it an application group (imported from some other application, like Workday, Google, etc)?

---

<div class="post-metadata">

**Author:** ![jason.whisnant](https://avatars.discourse-cdn.com/v4/letter/j/50afbb/32.png) [@jason.whisnant](https://devforum.okta.com/u/jason.whisnant)\
**Post date:** [February 17, 2023, 4:32pm UTC](https://devforum.okta.com/t/error-adding-user-to-group-via-api/23378/7 "2023-02-17T16:32:22Z")

</div>

This is a group that was created by us locally in Okta. It wasn’t imported from the O365 application.

---

<div class="post-metadata">

**Author:** ![jason.whisnant](https://avatars.discourse-cdn.com/v4/letter/j/50afbb/32.png) [@jason.whisnant](https://devforum.okta.com/u/jason.whisnant)\
**Post date:** [February 20, 2023, 3:16pm UTC](https://devforum.okta.com/t/error-adding-user-to-group-via-api/23378/8 "2023-02-20T15:16:45Z")

</div>

Any further ideas on what could be causing this? We wound up having to brute force add the users to groups, but would still like to have this functionality

---

<div class="post-metadata">

**Author:** ![andrea](https://sea1.discourse-cdn.com/oktadev/user_avatar/devforum.okta.com/andrea/32/2172_2.png) [@andrea](https://devforum.okta.com/u/andrea)\
**Post date:** [February 21, 2023, 5:25pm UTC](https://devforum.okta.com/t/error-adding-user-to-group-via-api/23378/9 "2023-02-21T17:25:03Z")

</div>

Would you be able to share the value for the `x-okta-request-id` response header when you make this request so I can try to check our logs for more details?

---

<div class="post-metadata">

**Author:** ![jason.whisnant](https://avatars.discourse-cdn.com/v4/letter/j/50afbb/32.png) [@jason.whisnant](https://devforum.okta.com/u/jason.whisnant)\
**Post date:** [February 21, 2023, 7:04pm UTC](https://devforum.okta.com/t/error-adding-user-to-group-via-api/23378/10 "2023-02-21T19:04:30Z")

</div>

I am currently not seeing that as a response header in Postman. Is there something that I need to add to the headers or body of the request? Current response headers are Date, Content-Type, Transfer-Encoding, Connection, Server, Public-Key-Pins-Report-Only, x-content-type-options, and Strict-Transport-Security.

---

<div class="post-metadata">

**Author:** ![andrea](https://sea1.discourse-cdn.com/oktadev/user_avatar/devforum.okta.com/andrea/32/2172_2.png) [@andrea](https://devforum.okta.com/u/andrea)\
**Post date:** [February 21, 2023, 9:29pm UTC](https://devforum.okta.com/t/error-adding-user-to-group-via-api/23378/11 "2023-02-21T21:29:25Z")

</div>

Hmm… it should just come back when you make the request to Okta

 ![Screen Shot 2023-02-21 at 1.28.17 PM](https://global.discourse-cdn.com/oktadev/original/2X/d/da48f49c3945dfa7471c2a6a87456118895b400a.png)

---

<div class="post-metadata">

**Author:** ![jason.whisnant](https://avatars.discourse-cdn.com/v4/letter/j/50afbb/32.png) [@jason.whisnant](https://devforum.okta.com/u/jason.whisnant)\
**Post date:** [February 21, 2023, 9:51pm UTC](https://devforum.okta.com/t/error-adding-user-to-group-via-api/23378/12 "2023-02-21T21:51:09Z")

</div>

It does when I do a different request (for example, a search of groups GET {{url}}/api/v1/groups?q=365), but when I try the PUT request detailed above, I only get the headers that I listed along with the status message “405 Method Not Allowed” as previously detailed.

 ![image](https://global.discourse-cdn.com/oktadev/original/2X/f/f26520de6e3f080ca2b0e72a39280b61b04562af.png)

---

<div class="post-metadata">

**Author:** ![andrea](https://sea1.discourse-cdn.com/oktadev/user_avatar/devforum.okta.com/andrea/32/2172_2.png) [@andrea](https://devforum.okta.com/u/andrea)\
**Post date:** [February 21, 2023, 10:03pm UTC](https://devforum.okta.com/t/error-adding-user-to-group-via-api/23378/13 "2023-02-21T22:03:15Z")

</div>

Are you sure you have the `groupId` variable set correctly? I’m seeing GETs to this URL that look like this that are returning a 405: `/api/v1/groups/groupId/users/00u16041nqJqudi6p697`

Also, you will want to remove the `-admin` from your `{{url}}` variable, as its not needed when making API calls to your org

---

<div class="post-metadata">

**Author:** ![jason.whisnant](https://avatars.discourse-cdn.com/v4/letter/j/50afbb/32.png) [@jason.whisnant](https://devforum.okta.com/u/jason.whisnant)\
**Post date:** [February 21, 2023, 10:22pm UTC](https://devforum.okta.com/t/error-adding-user-to-group-via-api/23378/14 "2023-02-21T22:22:28Z")

</div>

Thank you for pointing out the issue with the variable. I fixed it then ran a request replacing the variable with the actual group ID. Just to be safe, I also replaced the url to remove -admin from it and then ran the test again in Postman with the variables replaced with the actual information the variable represented. New call was PUT \<orgname\_redacted\>.okta.com/api/v1/groups//users/ and still got the 405 error. Do you see the most recent call?

Date: Tue, 21 Feb 2023 22:18:21 GMT

---

<div class="post-metadata">

**Author:** ![andrea](https://sea1.discourse-cdn.com/oktadev/user_avatar/devforum.okta.com/andrea/32/2172_2.png) [@andrea](https://devforum.okta.com/u/andrea)\
**Post date:** [February 22, 2023, 4:54pm UTC](https://devforum.okta.com/t/error-adding-user-to-group-via-api/23378/15 "2023-02-22T16:54:52Z")

</div>

I’m still seeing GETs on our side instead of PUTs, the most recent of which was at Feb 21 22:18:21 GMT.

---

<div class="post-metadata">

**Author:** ![jason.whisnant](https://avatars.discourse-cdn.com/v4/letter/j/50afbb/32.png) [@jason.whisnant](https://devforum.okta.com/u/jason.whisnant)\
**Post date:** [February 22, 2023, 5:37pm UTC](https://devforum.okta.com/t/error-adding-user-to-group-via-api/23378/16 "2023-02-22T17:37:48Z")

</div>

I used a curl command to try this and it seemed to work, or at least not error. Could you check x-okta-request-id: Y\_ZSOV7VnIVSdMlHsjZhpgAAD2Q and see if that shows as a PUT request?

---

<div class="post-metadata">

**Author:** ![andrea](https://sea1.discourse-cdn.com/oktadev/user_avatar/devforum.okta.com/andrea/32/2172_2.png) [@andrea](https://devforum.okta.com/u/andrea)\
**Post date:** [February 22, 2023, 8:09pm UTC](https://devforum.okta.com/t/error-adding-user-to-group-via-api/23378/17 "2023-02-22T20:09:30Z")

</div>

Yup, that one was a PUT that resulted in a 204, looks like the user was added successfully from what I can tell

---

<div class="post-metadata">

**Author:** ![jason.whisnant](https://avatars.discourse-cdn.com/v4/letter/j/50afbb/32.png) [@jason.whisnant](https://devforum.okta.com/u/jason.whisnant)\
**Post date:** [February 27, 2023, 4:53pm UTC](https://devforum.okta.com/t/error-adding-user-to-group-via-api/23378/18 "2023-02-27T16:53:07Z")

</div>

It looks like Postman is sending Put requests as Get requests… Thanks for all of the help!

---

<div class="post-metadata">

**Author:** ![system](https://global.discourse-cdn.com/oktadev/original/1X/589c4c5f80de422d01f47cee7185a7fb8227835c.png) [@system](https://devforum.okta.com/u/system)\
**Post date:** [February 28, 2023, 4:53pm UTC](https://devforum.okta.com/t/error-adding-user-to-group-via-api/23378/19 "2023-02-28T16:53:27Z")

</div>

This topic was automatically closed 24 hours after the last reply. New replies are no longer allowed.
