【发布时间】:2019-01-05 08:03:16
【问题描述】:
我正在尝试连接到 OPS API,但在尝试连接到 url 时出现错误。我得到了documentation(第34页)中详述的access_token,但是当我尝试连接到我感兴趣的url时,我得到一个“找不到名称或服务”错误。
文档指出(第 35 页)客户端应通过加密的 HTTPS 连接访问 OPS 资源,我认为这可能是我的代码中缺少的步骤(或不创建此错误)。
以下是我使用的代码(将 #### 替换为我的 access_token):
from http.client import HTTPSConnection
c = HTTPSConnection('ops.epo.org/3.2/rest-services/published-data/search?q=Automation', port=443)
headers2 = {'Authorization': ‘Bearer ########kv5’}
c.request('GET', '/', headers=headers2)
res = c.getresponse()
data = res.read()
非常感谢。
【问题讨论】:
标签: python api encode httpconnection get-request