I am using python requests
module, I send my params like this before:
requests.post(url=url, params=params)
but today, I find that I send my data like this, it fails, I change to this:
requests.post(url=url, data=params)
then it is ok, what is the difference between data
and params
?
I observed that the request got a header X-Requested-With:XMLHttpRequest
, is it because of this?
According to the requests documentation<\/a> :
<\/li>
<\/li><\/ul>To understand the difference between the two, see this answer<\/a> .
Since they ended up there, they are viewable by anyone who has access to the URL, which is why you shouldn't use query strings for sensitive data like passwords.
I never denied such a thing in my original answer, but let's take a closer look.
- <\/li>
- <\/li><\/ul>
But that doesn't mean they are mutually exclusive.
"
First of all, there are two different methods<\/strong> :
<\/li>
<\/li><\/ul> Then, according to the docs<\/a> , you can choose between two parameters<\/strong> to send all the key\/value data:
<\/li>
<\/li><\/ul> So, you have 4 choices to send your request:
requests.post()<\/code> but using requests.get()<\/code> in his own example.
"
Params are sent in (appended to) the URI ( http://www.answer.com/here?param1=1¶m2=2
) while data is sent in the request body . Usually sensitive data or that sent in large volumes is posted in the body because it's easier to secure and doesn't lead to huge URIs.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.