【发布时间】:2013-10-26 17:29:04
【问题描述】:
POST https://maxcvservices.dnb.com/rest/Authentication
x-dnb-user: MyUsername
x-dnb-pwd: MyPassword
是 D&B API 的文档,因此我尝试使用以下代码行使用 python 请求模块发送 POST 请求:
r = requests.post('https://maxcvservices.dnb.com/rest/Authentication',params={'x-dnb-user':userid,'x-dnb-pwd':pass})
我得到的回复是Response [500]
回复内容为:error processing request\r\n
我的问题是我在传递 post 请求和参数时是否做错了,还是我的用户名和密码无效?
我觉得问题在于我传递 POST 请求的方式,因为 API 以单独的错误 401 响应用户 ID 不正确,通过。
{'connection': 'Keep-Alive',
'content-encoding': 'gzip',
'content-length': '46',
'content-type': 'text/plain',
'date': 'Sat, 26 Oct 2013 17:43:22 GMT',
'server': '',
'vary': 'Accept-Encoding',
'x-correlationid': 'Id-d4c07ad3526bff3a03fb742e 0'}
我使用时的响应头:
r = requests.post('https://maxcvservices.dnb.com/rest/Authentication', headers={'x-dnb-user': 'userid', 'x-dnb-pwd': 'password'})
一个随机的用户 ID 和密码。
但根据 API 我应该收到 <Response [401]> 。
我收到的是<Response [500]>。
【问题讨论】:
标签: python http-post python-requests