# Bug in occurrence/download/request API when using axios-retry

**URL:** <https://discourse.gbif.org/t/bug-in-occurrence-download-request-api-when-using-axios-retry/4264>\
**Category:** Miscellaneous\
**Created:** [January 25, 2024, 9:50am UTC](https://discourse.gbif.org/t/bug-in-occurrence-download-request-api-when-using-axios-retry/4264 "2024-01-25T09:50:26Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![neil](https://avatars.discourse-cdn.com/v4/letter/n/839c29/32.png) [@neil](https://discourse.gbif.org/u/neil)\
**Post date:** [January 25, 2024, 9:50am UTC](https://discourse.gbif.org/t/bug-in-occurrence-download-request-api-when-using-axios-retry/4264/1 "2024-01-25T09:50:26Z")

</div>

The /occurrence/download/request API route is no longer behaving correctly. It is now always returning a download ID of `0041096-231120084113126` regardless of the query. This is an 862Gb file.

The problem is not the polygon passed to the ‘within’ predicate because I have tried other polygons (e.g. the one from the [documentation](https://techdocs.gbif.org/en/data-use/api-downloads.html#within)).

The problem may well happen for _all_ requests e.g. I tried the `geoDistance` example from the [docs](https://techdocs.gbif.org/en/data-use/api-downloads.html#geodistance):

```auto
"predicate": {
    "type": "geoDistance",
    "latitude": "90",
    "longitude": "100",
    "distance": "5km",
  }

```

I have also tried a separate user account and the same problem occurs.

I’d be grateful if the dev team could look into it.

Many thanks,  
Neil

---

<div class="post-metadata">

**Author:** ![mgrosjean](https://avatars.discourse-cdn.com/v4/letter/m/97f17d/32.png) [@mgrosjean](https://discourse.gbif.org/u/mgrosjean)\
**Post date:** [January 25, 2024, 10:09am UTC](https://discourse.gbif.org/t/bug-in-occurrence-download-request-api-when-using-axios-retry/4264/2 "2024-01-25T10:09:20Z")

</div>

Hi @neil thank you for reporting the issue.

It looks like the geo distance example in the documentation is incorrect (the trailing comma is the issue), we will correct it, thanks!

The downloads seem to work as far as I can see. Would it be possible to send your full script to [helpdesk@gbif.org](mailto:helpdesk@gbif.org) so we can investigate a bit more? Thank you!

---

<div class="post-metadata">

**Author:** ![neil](https://avatars.discourse-cdn.com/v4/letter/n/839c29/32.png) [@neil](https://discourse.gbif.org/u/neil)\
**Post date:** [January 25, 2024, 1:40pm UTC](https://discourse.gbif.org/t/bug-in-occurrence-download-request-api-when-using-axios-retry/4264/3 "2024-01-25T13:40:02Z")

</div>

Thank you for the reply. I created a minimal example to reproduce the problem. It appears that the problem happens when using `axios-retry` but not when using plain `axios`. Full details in an email to the helpdesk.

I can work around the issue by using plain axios but I still suspect that something strange is happening server side because returning an old download ID (`0041096-231120084113126`) doesn’t seem right. If `axios-retry` was messing up the request somehow then I’d expect the server to give an error.

---

<div class="post-metadata">

**Author:** ![MattBlissett](https://avatars.discourse-cdn.com/v4/letter/m/58956e/32.png) [@MattBlissett](https://discourse.gbif.org/u/MattBlissett)\
**Post date:** [January 25, 2024, 3:10pm UTC](https://discourse.gbif.org/t/bug-in-occurrence-download-request-api-when-using-axios-retry/4264/4 "2024-01-25T15:10:42Z")

</div>

In case it helps work out what’s happening, `0041096-231120084113126` is this month’s all-data DWCA-format download. Download requests for all data are pointed to this download, rather than recreating a ~900GB file (this takes hours). It should mean the request is arriving without a `predicate` value.

---

<div class="post-metadata">

**Author:** ![neil](https://avatars.discourse-cdn.com/v4/letter/n/839c29/32.png) [@neil](https://discourse.gbif.org/u/neil)\
**Post date:** [January 25, 2024, 5:41pm UTC](https://discourse.gbif.org/t/bug-in-occurrence-download-request-api-when-using-axios-retry/4264/5 "2024-01-25T17:41:53Z")

</div>

Thank you Matt - that helps. The bug was on our end - passing the POST body to the `axios-retry` with an extra layer of nesting in the JSON i.e. the usual payload was wrapped in `{ data: theUsualPayload }`.

You’re right Matt, that the request arrived without a `predicate` but there doesn’t appear to have been any other validation of the request body. Detecting that `data` was an unexpected attribute and generating an error would have helped track down the error more swiftly.

Thanks again,  
Neil

---

<div class="post-metadata">

**Author:** ![MattBlissett](https://avatars.discourse-cdn.com/v4/letter/m/58956e/32.png) [@MattBlissett](https://discourse.gbif.org/u/MattBlissett)\
**Post date:** [January 26, 2024, 12:24pm UTC](https://discourse.gbif.org/t/bug-in-occurrence-download-request-api-when-using-axios-retry/4264/6 "2024-01-26T12:24:57Z")

</div>

Glad to hear that Neil.

The general design of the API is to ignore unknown parameters. A predicate of `{}` is the way to request a full download, and `{"data": …}` is therefore seen the same way.

Similar cases have happened before; I’ve reopened [Invalid queries in occurrence downloads are silently ignored · Issue #273 · gbif/occurrence · GitHub](https://github.com/gbif/occurrence/issues/273) so we can see if this could be improved.

---

<div class="post-metadata">

**Author:** ![system](https://global.discourse-cdn.com/gbif1/original/1X/d2525d53d815eb0c992cc44730ed8a6a1be1dbb5.png) [@system](https://discourse.gbif.org/u/system)\
**Post date:** [February 25, 2024, 10:25pm UTC](https://discourse.gbif.org/t/bug-in-occurrence-download-request-api-when-using-axios-retry/4264/7 "2024-02-25T22:25:35Z")

</div>

Closed on February 25, 2024, 10:25pm UTC

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.
