我正试着和我的Marketo使用木星(Anaconda)和请求包。我不介意创建auth令牌,但是仍然停留在对端点的实际调用上。
host = "https://my_mtko_instance.com"
leadId = "13000000"
endpoint = "/rest/v1/lead/" + leadId + ".json"
auth_token = "?access_token=" + mkto_token
getLead = requests.get(host+endpoint+leadId+auth_token)
print(host+endpoint+auth_token)
getLead.json()我得到一个` `JSONDecodeError:期望值:第1行第1列(char 0)
有趣的是,我可以单击print()中的URL,这样我就可以在浏览器中看到一个JSON查找响应。
发布于 2018-09-16 20:02:07
我认为问题在于如何为get请求组装url。
请注意,端点的正确格式是:
https://<mkto_instance>.mktorest.com/rest/v1/lead/{leadId}.json
但是,使用host+endpoint+leadId+auth_token格式,您可以两次插入leadId变量,因为endpoint变量已经包含它。
将调用更改为requests.get(host+endpoint+auth_token),它应该可以正常工作。
https://stackoverflow.com/questions/52340758
复制相似问题