I am trying to query a server with a POST method in Python.
import requests
url = "https://www.test.com/service"
data = {"param": "value"}
req = requests.post(url, data).content
When I look at req, it clearly doesn't take into account the data I posted.
If I check the header with cURL:
curl -ik -X POST -d "param=value" https://www.test.com/service
I get the following HTTP 302:
HTTP/1.1 302 Déplacé Temporairement
Date: Fri, 06 Oct 2017 16:42:36 GMT
Server: Apache-Coyote/1.1
X-Content-Type-Options: nosniff
X-XSS-Protection: 1; mode=block
Cache-Control: no-cache, no-store, max-age=0, must-revalidate
Pragma: no-cache
Expires: 0
Location: https://www.test.com/redirect
Content-Language: fr-FR
Content-Length: 0
Via: 1.1 www.test.com
So if I understand well, I am redirected to Location which is https://www.test.com/redirect. This address can only be query with a GET method; if I try with a POST, I get a HTTP 500 error.
What I understand thus is that I am POSTing a request with parameters and I am redirected to another page and the request becomes a GET, querying Location. I don't understand then what happens to my parameters: in my browser, I get an answer that takes into account the parameters sent, when I query it by hand they seem to be "lost" since I just get kind of an empty version of https://www.test.com/redirect.
What do I miss? My understanding of requests is pretty shallow so I'm sure I'm missing something obvious.