Post Request ok with postman but failed using code in python
Author: porikitoCreated Apr 3, 2019Updated Mar 23, 2025
Hi 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.
Source: request/request