Send GET Request with Python Curl with Requests package to Swagger API

Hi Guys,

I’ve recently created another thread that is more related to seeking out for some general guidance on building a web application around TTN:

This thread is more related to Python ↔ Swagger interaction. I would like to send a Curl GET request to the swagger and show the body, I’m using following tool to convert the Curl get request syntax provided by the swagger page:
https://curl.trillworks.com/
and following python code:

  import requests

headers = {
    'Accept': 'application/json',
    'Authorization': 'key ttn-account-notsharinganything',
}

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

response = requests.get('https://notsharinganything.data.thethingsnetwork.org/api/v2/query/heltec2', headers=headers, params=params)
print(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://notsharinganything.data.thethingsnetwork.org/api/v2/query/heltec2?last=1h', headers=headers)

I just receive 200 as response, which means that I can authenticate with the swagger. However, I would like to display the ‘body content’ and not the ‘response code’.
Exact output: <Response [200]>

The type of response in the code is following:
<class ‘requests.models.Response’>
https://requests.readthedocs.io/en/v0.6.2/api/

Try response.content

@descartes : thank you, that worked. It fails like a little fail, I couldn’t find that in the documentation but I could have screened what methods/variables are stored in response in my IDE.

Do you know where I can find the documentation on that?

From the link on the requests.readthedocs.io you supplied!

@descartes thank you, btw.: will also all the open source LoRa libraries for Arduino have to be updated when switching from v2 → v3?

Here it reads that the data formats have to be adjusted:
https://www.thethingsindustries.com/docs/getting-started/migrating/migrating-from-v2/

https://www.thethingsindustries.com/docs/reference/data-formats/

Do the CPP and h files need to be adapted accordingly?

No, libraries that are already compliant with the specification for LoRaWAN work just fine.

It’s only the format of the data that gets sent to you that’s being extended & updated.