我试图从 The Trade Desk 的(沙盒)api 获取身份验证令牌,但收到 400 响应,指出:
“将内容类型‘application/json’读取为 JSON 时出错:意外
解析值时遇到的字符:L.Path '',第 0 行,
位置 0。”
Whole response.json()
:
{u'ErrorDetails': [{u'Reasons': [u"Error reading Content-Type 'application/json' as JSON: Unexpected character encountered while parsing value: L. Path '', line 0, position 0."], u'Property': u'TokenRequest'}], u'Message': u'The request failed validation. Please check your request and try again.'}
我的脚本(可运行):
import requests
def get_token():
print "Getting token"
url = "https://apisb.thetradedesk.com/v3/authentication"
headers = {'content-type': 'application/json'}
data = {
"Login":"logintest",
"Password":"password",
"TokenExpirationInMinutes":60
}
response = requests.post(url, headers=headers, data=data)
print response.status_code
print response.json()
return
get_token()
沙箱文档在这里 https://apisb.thetradedesk.com/v3/doc
我相信这意味着我的headers
var 没有被正确序列化requests
,这似乎不可能,或者 The Trade Desk 没有正确反序列化。我已经进入了requests
lib,但我似乎无法破解它,正在寻找其他输入。