简体   繁体   中英

what is the difference between data and params in requests?

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?

First of all, there are two different methods<\/strong> :

Params are sent in (appended to) the URI ( http://www.answer.com/here?param1=1&param2=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.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM