我一直在運行腳本時在我的終端中收到<Response [400]>
。如何在Python中進行POST時修復<Response [400]>?
我已經試過
import requests
import json
url = 'http://172.19.242.32:1234/vse/account'
data = '{
"account_id": 1008,
"email_address": "[email protected]",
"password": "qqq",
"account_type": "customer",
"name_prefix": "",
"first_name": "Beverly",
"middle_names": "",
"last_name": "Hills",
"name_suffix": "",
"non_person_name": false,
"DBA": "",
"display_name": "BeverlyHills",
"address1": "4984 Beverly Dr",
"address2": "4984 Beverly Dr",
"address3": "",
"city": "Beverly Hills",
"state": "CA",
"postal_code": "90210",
"nation_code": "90210",
"phone1": "3105554984",
"phone2": "",
"phone3": "",
"time_zone_offset_from_utc": -5,
"customer_type": "2",
"longitude": -118.4104684,
"latitude": 34.1030032,
"altitude": 0
}'
headers = {'content-type': 'application/json'}
r = requests.post(url, data=json.dumps(data), headers=headers)
print r
我做了什麼錯?
什麼是響應正文? – Kos
我怎麼看? – ihue
[有一些屬性和方法,如'.text','.content','.json()'](http://docs.python-requests.org/en/master/user/quickstart/#response-內容) – Kos