Forums

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

This resource requires WebSudo

Daniel
Contributor
July 4, 2023

I'm trying to use Confluence's REST API to disable users:

# Confluence REST API Configuration
confluence_url = 'http://localhost:8888/rest/api'
confluence_token = 'token'
headers = {'Authorization': f'Bearer {confluence_token}'}
...
...
try:
# Execute the SQL query
cursor = connection.cursor()
cursor.execute(sql_query)

# Fetch the result
users = cursor.fetchall()

# Loop through users and print them out
for user, last_login in users:
print(f"User: {user}, last login: {last_login}")

# API endpoint to disable a user
disable_user_url = f"{confluence_url}/admin/user/{user}/disable"

# Making a PUT request to disable the user
response = requests.put(disable_user_url, headers=headers)

# Printing the response
print(f"Response: {response.status_code}, {response.text}")

finally:
# Close the connection
connection.close()

Ignore the indentation. The error I get is:

Response: 401, <?xml version="1.0" encoding="UTF-8" standalone="yes"?><status><status-code>401</status-code><message>This resource requires WebSudo.</message></status> 

Also ignore the localhost part, I'm port forwarding.

 

I don't understand what I need to do. I want to automate this process and run it as a cron job.

 

 

Edit because I can't comment for some reason:

I managed to get around Websudo by using my username and password with basic authentication, just had to use secrets :)

Thanks!

2 answers

0 votes
David Yu
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
August 29, 2023

This seems like a bug. APIs shouldn't require websudo.

David Yu
Contributor
August 30, 2023

After some more testing, it seems that the use of cookies is not possible, and you must supply the basic auth headers with each call.

AutomationUIUser November 15, 2023

Hi , we have faced a similar issue with the http://<jirahost>/rest/api/2/workflowscheme/{workflowschemeid}/workflow API on the on-premise jira instance with cookie based authentication, can you please let us know it is expected behavior?

0 votes
Craig Nodwell
Community Champion
July 4, 2023

Hi @Daniel here's a page for your reference hope it helps.

Suggest an answer

Log in or Sign up to answer
DEPLOYMENT TYPE
SERVER
VERSION
8.3.0
TAGS
AUG Leaders

Atlassian Community Events