gpt4 book ai didi

python - 在 Python 中进行 POST 时如何修复

转载 作者:行者123 更新时间:2023-12-05 09:19:53 28 4
gpt4 key购买 nike

我不断收到 <Response [400]>运行脚本时在我的终端中。

我试过了

import requests
import json

url = 'http://172.19.242.32:1234/vse/account'

data = '{
"account_id": 1008,
"email_address": "bhills_4984@mailinator.com",
"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

我做错了什么?

最佳答案

改变

r = requests.post(url, data=json.dumps(data), headers=headers)

r = requests.post(url, data=data, headers=headers)

因为data不是必须转成json的dict,而是已经是json了。

关于python - 在 Python 中进行 POST 时如何修复 <Response [400]>?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39257168/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com