gpt4 book ai didi

python - python转换JSON请求时出现 "httpMessageNotReadableException"的错误消息

转载 作者:行者123 更新时间:2023-12-01 02:57:14 24 4
gpt4 key购买 nike

我在处理 json 格式的 Rest API 请求时遇到问题,该请求无法转换。请求代码如下所示:

headers = {"content-type": "application/json","username": "xxx" , "password": "xxx" , "domain": "xxx" }

r = requests.post("https://psepmlan1:8446/sepm/api/v1/identity/authenticate",headers=headers,verify=False)

print r.content

我收到的错误如下所示:

{"errorCode":"500","errorMessage":"org.springframework.http.converter.HttpMessageNotReadableException"}

我尝试阅读有关此错误的一些问题,并且我了解这是关于传递 json 请求的方式,但我无法发送正确的请求。

有什么建议吗?

最诚挚的问候

最佳答案

假设我们有“a.json”。请在发布请求时执行这些操作。

json_data=open('a.json', 'r')

values = json.load(json_data)

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

这会起作用。我得到了和你一样的错误。

关于python - python转换JSON请求时出现 "httpMessageNotReadableException"的错误消息,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44093565/

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