微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

使用带有请求包的 Python Curl 发送 GET 请求到 TTN Swagger API:如何获取正文内容

如何解决使用带有请求包的 Python Curl 发送 GET 请求到 TTN Swagger API:如何获取正文内容

这个问题与使用带有 curl get 请求的请求包有关。

我想向 TTN swagger 发送 Curl GET 请求并显示正文。 swagger 的 TheThingsNetwork API:https://www.thethingsnetwork.org/docs/applications/storage/api.html 我正在使用以下工具来转换 swagger 页面提供的 Curl get 请求语法: https://curl.trillworks.com/ 和以下python代码

import requests

headers = {
    'Accept': 'application/json','Authorization': 'key ttn-account-v2.o-bliRC09pUnCwcg8fU2pHS8eQHjZJPxSjm7h8kDfOI',}

params = (
    ('last','1h'),)

response = requests.get('https://heltec_ecosoph.data.thethingsnetwork.org/api/v2/query/heltec2',headers=headers,params=params)
print(type(response))

#NB. Original query string below. It seems impossible to parse and
#reproduce query strings 100% accurately so the one below is given
#in case the reproduced version is not "correct".
# response = requests.get('https://heltec_ecosoph.data.thethingsnetwork.org/api/v2/query/heltec2?last=1h',headers=headers)

我只收到 200 作为响应,这意味着我可以使用 swagger 进行身份验证。但是,我想显示正文内容”而不是“响应代码”。 精确输出

代码中的响应类型如下: https://requests.readthedocs.io/en/v0.6.2/api/

正文应如下所示: enter image description here

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。