requests.post with Authentication giving error 415 for jira rest api in python

R.Ram
url = "https://example.com/jira/rest/api/2/issue/issue_key/comment"
data = json.dumps({"body": 'some string'})
headers = {'content-type':'application/json'}
r = requests.post(url, data, auth=('username', 'password'))

--> r.status_code output is 415.

But in case of

r = requests.get(url, data, auth=('username', 'password'))

--> r.status_code output is 200. Please help me to identify issue.

JustOneQuestion

you forgot to add the headers variable to your post requests. thats why it fails. just add this to your post request and you should get a 201 status code as response:

r = requests.post(url, data, auth=('username', 'password'), headers=headers)

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related