我想打电话给网络服务。当从Postman和Python脚本调用时,我得到了不同的结果
以下是python脚本:
url = 'https://api.dinero.dk/v1/257403/contacts'
payload="{\r\n'Name': 'Lars5',\r\n'Street': 'Præsteager 5',\r\n'ZipCode': '8200',\r\n'City': 'Aarhus N',\r\n'CountryKey': 'DK',\r\n'Phone': '+45 12 34 56 78',\r\n'Email': 'test1@test.com'\r\n}"
headers = {'Content-Type': 'application/json','Authorization': 'Bearer ' + token}
response = requests.request('POST', url, headers=headers, data=payload)
它返回状态500
如果我在《邮递员》中也这么做:
然后我得到状态201
有什么区别
在postman中,json格式错误,json应该使用双引号而不是单引号,json中没有单引号,而在postman中,它会正确地突出显示,并带有语法错误
您是否从原始正文下拉列表中选择了json
将正文的单引号替换为双引号,这样可以解决一半的问题
相关问题 更多 >
编程相关推荐