Objective
In the post request, sometimes the body part to pass the data parameter, and sometimes the body part of the JSON parameter, then the question is: When to pass the JSON, when should pass data?
I. Identification of JSON parameters
1. In the previous 1.8 chapters, the body of the POST request usually has four types, the most common is the JSON format, this is still a lot of recognition
2. Using the Grab Bag tool to view, first open raw to see the body section, such as this, the parameter is the most outside the curly brace {} Wrapped up, this has been diagnosed as JSON format.
3. Once again, you can click on the JSON to view, click to see a few sets of parameters here are JSON parsed
4. At this time, you can use the preceding 2.2 to transmit the JSON parameters
Ii. Identification of data parameters
The 1.data parameter is this format: key1=value1&key2=value2 ... This format is obviously not curly braces
Open raw view, with the above JSON difference is still very big
2. Because this is a non-JSON, so the point of opening the JSON menu is not parsed data, this data in the WebForms inside the view
3. You can see that this parameter is displayed in the body section, the name on the left is the key value, and the value on the right is the corresponding value value, like this parameter conversion from the Python dictionary format is OK
4. This type of post when the data parameter can be transmitted, the format is as follows:
s = requests.session ()
r = S.post (URL, headers=headers, Data=d) # Here's D is the parameter of the dictionary format in the previous step
Python interface Automation 13-data and JSON parameters silly confusing