python - How to replace token(bearer) with username, password in Cherwell REST API request -


i trying create rfc in cherwell using rest api in python. tried first in swegger ui. got working there. able create rfc successfully. following curl request, in python, using request module, tried , got 401. found why getting 401. it's because of in authorization using bearer temporary token. live 10 minutes. if request after 10 minutes got 401. bearer compulsory field. can't make request without it. tried pass username , password instead of bearer, didn't work. below request,

with open('c:\cherwell\payload.json') file: data = json.load(file) payload = data header = {"authorization":"bearer xxxxxxxx"} r = requests.post("https:/url/cherwellapi/api/v1/savebusinessobject? api_key=xxxx-xxxx-xxxx-xxxx", auth=('user','pass'), headers = header,  data=json.dumps(payload)) print r 

it great, if can have done before! please advice

appreciate help!

using call get token can access token , using can request create new ticket. worked me.


Comments

Popular posts from this blog

php - Permission denied. Laravel linux server -

google bigquery - Delta between query execution time and Java query call to finish -

python - Pandas two dataframes multiplication? -