Post Request ok with postman but failed using code in python
See original GitHub issueHi everybody,
I’m trying to write a little python code to get a json list from an website Api.
with postman i use the url and the two needed params and the result is good (as you can see in postman picture.
After this i take postman to generate the python Code related to this query, the result is like this
import requests
url = "https://ww5.files-seekr.com/api/search/all"
payload = "------WebKitFormBoundary7MA4YWxkTrZu0gW\r\nContent-Disposition: form-data; name=\"query\"\r\n\r\nbatman\r\n------WebKitFormBoundary7MA4YWxkTrZu0gW\r\nContent-Disposition: form-data; name=\"api_key\"\r\n\r\n1305ca510f59d2d1\r\n------WebKitFormBoundary7MA4YWxkTrZu0gW--"
headers = {
'content-type': "multipart/form-data; boundary=----WebKitFormBoundary7MA4YWxkTrZu0gW",
'cache-control': "no-cache",
'postman-token': "eae0d2e2-be2b-b95b-aebd-15226e17eed4"
}
response = requests.request("POST", url, data=payload, headers=headers)
print(response.text)
And using python Gui, the result is not ok (error 405)
i’ve tried using different syntax of the python code with no success (this following is one of them)
import requests
url = "https://ww5.files-seekr.com/api/search/all"
payload = {'api_key': '1305ca510f59d2d1', 'query': 'batman'}
response = requests.post(url=url, data=payload)
print(response.text)
Can someone give me a little help ?
Thanks a lot.
Issue Analytics
- State:
- Created 4 years ago
- Comments:29
Top Results From Across the Web
POST request works in Postman but not in Python
When I do it in Python 2.7 (using a Jupyter notebook), I get the error "No JSON object could be decoded". What am...
Read more >Not getting any output using python, but using Postman i am ...
Using POSTMAN, first i used POST to get the session ID, second GET to get the output response. In POSTMAN,. 1) POST: import...
Read more >Post requests works on postman but not on python3 - Help
I sent a post requests using postman in this URL: my form-data was: u: ... But the automated python code is not working...
Read more >Post Method works for Postman but Python - Infoblox Community
I coud achieve post requests via Postman when i try in python code which gives below error. I read its because of role,...
Read more >API calls work in Postman but not in Powershell or Python
Im just trying to get a list of finished reports at this point but it doesn't matter what I do, all calls work...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Wait. Which Python? This is a JavaScript library.
Thanks @GSManganneau.
This did not work
But this did
That’s in Python 2.7, Requests 2.23.0.