我在使用Python处理EatStreet公共API的GET请求时遇到问题。我已经成功地使用了站点上的其他端点,但是我不确定如何处理这个实例中的路径参数。你知道吗
此curl请求返回200:
卷曲-X得到\ -H'X-Access-Token:API\u EXPLORER\u AUTH\u KEY'\ 'https://eatstreet.com/publicapi/v1/restaurant/90fd4587554469b1f15b4f2e73e761809f4b4bcca52eedca/menu?includeCustomizations=false'
这是我目前拥有的,但我不断得到错误代码404。我尝试了多种其他方法来处理参数和标题,但似乎没有任何效果。你知道吗
api_url = 'https://eatstreet.com/publicapi/v1/restaurant/
90fd4587554469b1f15b4f2e73e761809f4b4bcca52eedca/menu'
headers = {'X-Access-Token': apiKey}
def get_restaurant_details():
response = requests.request("GET", api_url, headers=headers)
print(response.status_code)
if response.status_code == 200:
return json.loads(response.content.decode('utf-8'))
else:
return None
以下是EatStreet公共API的链接: https://developers.eatstreet.com/
Passing Parameters In URLs
通过打印URL,您可以看到URL已正确编码:
所以在你的情况下可能看起来像
相关问题 更多 >
编程相关推荐