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!
This seems like a bug. APIs shouldn't require websudo.
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.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Online forums and learning are now in one easy-to-use experience.
By continuing, you accept the updated Community Terms of Use and acknowledge the Privacy Policy. Your public name, photo, and achievements may be publicly visible and available in search engines.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.