【问题标题】:How do I fetch response from rest api如何从 rest api 获取响应
【发布时间】:2020-12-04 05:11:40
【问题描述】:

我的请求如下所示:

GET /entity/name.json?entity_id=add7cd797ccb92a7934f3352&entity_type=xxxxx&auth_token=xxxx HTTP/host/v1.1
Host: host_ip:rest_api_port

如何从该调用中获取响应。我无法使用请求库来做到这一点

【问题讨论】:

  • 到目前为止你尝试了什么?请分享您的代码
  • 您在使用请求库时遇到的任何特定错误??

标签: python api get fetch-api


【解决方案1】:

将响应分配给一个变量并从中获取 json。

response = requests.get(http://host_ip:rest_api_port/host/v1.1/entity/name.json?entity_id=add7cd797ccb92a7934f3352&entity_type=xxxxx&auth_token=xxxx)

response_json = response.json()

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2019-05-12
    • 1970-01-01
    • 2022-06-30
    • 2015-10-28
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2022-12-02
    相关资源
    最近更新 更多