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?
The post() method sends a POST request to the specified url. The post() method is used when you want to send some data to the server.
To send parameters in URL, write all parameter key:value pairs to a dictionary and send them as params argument to any of the GET, POST, PUT, HEAD, DELETE or OPTIONS request. then https://somewebsite.com/?param1=value1¶m2=value2 would be our final url.
In a POST request, the parameters are sent as a body of the request, after the headers. To do a POST with HttpURLConnection, you need to write the parameters to the connection after you have opened the connection.
You'll want to adapt the data you send in the body of your request to the specified URL. Syntax: requests. post(url, data={key: value}, json={key: value}, headers={key:value}, args) *(data, json, headers parameters are optional.)
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 adict
, that data will be posted directly.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With