Search code examples
mendeley

Mendeley API File retrieval by id fails with response code 0


I'm experimenting with the Mendeley API to upload and retrieve documents and files and have a problem with the files/{file_id} endpoint. I have a personal Mendeley account I'm using for testing, populated with some PDF documents.

For example, on the API documentation page if I call

GET /files 

I see all the files I've added, but if I take an id value, then call

GET /files/{file_id}

using the ID, e.g.

https://api.mendeley.com:443/files/7b188de2-32a7-f067-51bd-520179e866b8

I get a strange response code of 0, response headers is {}, response body is 'no content'. This happens with all the ids from the file listing - is this a bug or am I doing something wrong?

If I alter the id string, I get a 404 Not found error, which is to be expected, so it's not an authorisation or other general issue.


Solution

  • It's a limitation of Swagger, the software that's used to run the API documentation web page.

    That endpoint returns a redirect to an S3 download URL, to allow you to grab the file. Unfortunately Swagger doesn't handle the redirect properly, and it shows it as a response code of 0.

    The endpoint is working correctly; it's just not displaying properly on the documentation page.