带有参数数据的Python请求发布
这是对API调用的原始请求: POST http://192.168.3.45:8080/api/v2/event/log?sessionKey=b299d17b896417a7b18f46544d40adb734240cc2&format=json HTTP/1.1 Accept-Encoding: gzip,deflate Content-Type: application/json Content-Length: 86 Host: 192.168.3.45:8080 Connection: Keep-Alive User-Agent: Apache-HttpClient/4.1.1 (java 1.5) {"eventType":"AAS_PORTAL_START","data":{"uid":"hfe3hf45huf33545","aid":"1","vid":"1"}}""" 该请求返回成功(2xx)响应。 现在,我尝试使用发送此请求requests: >>> import requests >>> headers = {'content-type' : 'application/json'} >>> data ={"eventType":"AAS_PORTAL_START","data{"uid":"hfe3hf45huf33545","aid":"1","vid":"1"}} >>> url = "http://192.168.3.45:8080/api/v2/event/log?sessionKey=9ebbd0b25760557393a43064a92bae539d962103&format=xml&platformId=1" >>> requests.post(url,params=data,headers=headers) <Response [400]> 一切对我来说看起来不错,我不太确定自己张贴的错误是什么引起400响应。