Hello,
I am trying to get a list of files from the bundle API endpoint, so that I can can bulk download them instead of downloading each file one by one from the UI tasks page. My problem is the GET bundle/{task_id} endpoint does not seem to work, returning a 403 error. The bearer token seems to be correct, as I am able to perform other account based activities like submitting and listing tasks.
```
# List bundle
def list_bundle(task_id:str, headers:dict):
endpoint = f'https://appeears.earthdatacloud.nasa.gov/api/bundle/{task_id}'
r = requests.get(endpoint, headers)
if r.status_code not in range (200, 299):
return r.status_code, r.json()
return r.json()
```
```
list_bundle('bd5964fc-2812-4449-9a97-1913b1c2b05f', headers=headers)
```
Thanks
Bundle Python API
-
- Posts: 249
- Joined: Thu Jun 25, 2020 9:51 am America/New_York
- Been thanked: 9 times
Re: Bundle Python API
Hi,
It looks like the code provided does not send the bearer token. Assuming that information is in the `headers` object, the `r = requests.get(endpoint,headers)` line needs to include `headers=headers` rather than in the call to the `list_bundle()` function.
For example:
token = token_response['token']
headers={'Authorization': 'Bearer {0}'.format(token)}
def list_bundle(task_id:str, headers:str):
endpoint = f'https://appeears.earthdatacloud.nasa.gov/api/bundle/{task_id}'
r = requests.get(endpoint, headers=headers)
if r.status_code not in range (200, 299):
return r.status_code, r.json()
return r.json()
list_bundle("bd5964fc-2812-4449-9a97-1913b1c2b05f ",headers)
Please refer to the current AρρEEARS API documentation for more details (https://appeears.earthdatacloud.nasa.gov/api/), and let us know if you have any other questions.
Regards,
The AρρEEARS Team
It looks like the code provided does not send the bearer token. Assuming that information is in the `headers` object, the `r = requests.get(endpoint,headers)` line needs to include `headers=headers` rather than in the call to the `list_bundle()` function.
For example:
token = token_response['token']
headers={'Authorization': 'Bearer {0}'.format(token)}
def list_bundle(task_id:str, headers:str):
endpoint = f'https://appeears.earthdatacloud.nasa.gov/api/bundle/{task_id}'
r = requests.get(endpoint, headers=headers)
if r.status_code not in range (200, 299):
return r.status_code, r.json()
return r.json()
list_bundle("bd5964fc-2812-4449-9a97-1913b1c2b05f ",headers)
Please refer to the current AρρEEARS API documentation for more details (https://appeears.earthdatacloud.nasa.gov/api/), and let us know if you have any other questions.
Regards,
The AρρEEARS Team