Forums

Articles
Create
cancel
Showing results for 
Search instead for 
Did you mean: 

Add user to Confluence group using REST API

Shroomy
Contributor
June 29, 2023

Hi,

I am trying to use the Confluence API to add a user to a group. I have tried this option.

api/user/{username}/group/{groupName}

 And I have used it in the following Python script:

import json
import os
import requests

confluence_url = os.environ['EXAMPLE_CONFLUENCE_URL']
confluence_pat = os.environ['EXAMPLE_CONFLUENCE_PAT']

headers = {
"Content-Type": "application/json",
'Authorization': 'Bearer ' + confluence_pat
}

json_data = {
'username': 'some.user@example.com',
'groupName': 'some-confluence-group',
}

api_endpoint = '/rest/api/user/'

url = confluence_url + api_endpoint

response = requests.put(url, headers=headers, json=json_data)

print(response.url)
print(response.status_code)

# Result:
# https://confluence.example.com/rest/api/user/
# 404

Not sure why I am getting a 404. I also don't understand what is meant by the {@link User} in the documentation.

1 answer

0 votes
Prabhu Palanisamy _Onward_
Atlassian Partner
June 30, 2023

HI - Are you able to invoke any other methods successfully? 404 usually indicate that resource end point is not available.

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events