Ankit Chaudhari
Ankit Chaudhari

Reputation: 305

How to pass a string to a post call, using python requests

I'm implementing a jira api call : Add watcher to a JIRA issue.

It takes a String parameter instead of JSON.

I'm using python requests.

requests.post(url, headers=headers, json=data)

What should be my value of data if the jira documentation says I need to pass just String but requests.post method only accepts JSON?

Upvotes: 13

Views: 27845

Answers (1)

Matheus Portela
Matheus Portela

Reputation: 2460

Simply do:

requests.post(url, headers=headers, data=data)

According to the official docs:

There are many times that you want to send data that is not form-encoded. If you pass in a string instead of a dict, that data will be posted directly.

Upvotes: 25

Related Questions