Some names are repeated, and some values are empty, such as sel_title. How to solve it?
I wrote the form like this. I don’t know what’s wrong. The result is 400 Bad Requests.
form={'begin_ap': 'a',
'begin_hh': '0',
'begin_mi': '0',
'end_ap': 'a',
'end_hh': '0',
'end_mi': '0',
'sel_attr': ['dummy', '%'],
'sel_camp': ['dummy', '%'],
'sel_crse': '512',
'sel_day': 'dummy',
'sel_from_cred': '',
'sel_insm': ['dummy', '%'],
'sel_instr': ['dummy', 'ED2E4E78451EB376949C4166DC00AFAF'],
'sel_levl': 'dummy',
'sel_ptrm': ['dummy', '%'],
'sel_schd': ['dummy', '%'],
'sel_sess': ['%', 'dummy'],
'sel_subj': ['dummy', 'STAT'],
'sel_title': '',
'sel_to_cred': '',
'term_in': '201810'}
You don’t know enough about the content type and structure of the http protocol
First of all, your form data is relatively complex, so the information header Content-Type: application/json is most suitable. The premise is that the server that receives the post request supports json parsing of the body
The server usually only supports or does not support body parsing:
application/x-www-form-urlencoded and
multipart/form-data
(nodejs express needs to add body-parser and multer plug-ins)
application/x-www-form-urlencoded is k1=v1&k2=v2...such a key=>str_val structure, so it is not suitable for your multi-level dictionary form data
About sending the form, the body part is json data
If your framework does not support parsing POST application/json by default, you need to perform a json parsing on the requested body raw data yourself to get the desired data
The code is as follows:
The results are as follows:
If it is empty, it depends on the definition of you and the background. It means passing an empty string
''
还是key
也不传,value
写None
Postman is recommended. You can use Postman to test the request form before writing code