How to connect to crowd via api

SBotalov
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
April 19, 2023

Hi 

I am trying to automate some tasks using Python script. And I need to connect to our company's Crowd application. I use the following pies of code to connect to Crowd.

But every time it returns 401 response.
I am in the crowd-administrators group.
Could you please advise on what I am doing wrong.

Thanks!


import requests

import json

crowd_url = 'https://*******.com/crowd'

username = '*********'

password = '***********************'

auth_url = f'{crowd_url}/rest/usermanagement/1/session'

auth_data = {'username': username, 'password': password}

auth_headers = {'Content-Type': 'application/json'}

auth_response = requests.post(auth_url, data=json.dumps(auth_data), headers=auth_headers)





1 answer

1 vote
SBotalov
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
August 28, 2023

resolved the problem via browser_cookie3 python library which takes cookies of the current session from the browser. so I passed cookies with post request

cookies = browser_cookie3.chrome(domain_name='lp-uat.luxoft.com') #get current cookies from the browser
cookies_dict = requests.utils.dict_from_cookiejar(cookies) #convert cookies to dict

r = requests.post(crowd_url, json=payload, cookies=cookies_dict)

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events