unioslo / tsd-file-api

REST API for upload and download of files and JSON data
BSD 3-Clause "New" or "Revised" License
0 stars 8 forks source link

Parameters not functioning as documented #253

Open pavelvazquez opened 2 weeks ago

pavelvazquez commented 2 weeks ago

Description

The per_page parameter in the API documentation https://github.com/unioslo/tsd-api-docs is supposed to control the number of files returned per request, with a maximum value of 50,000. However, when using this parameter, the API only returns 100 results regardless of the per_page value provided. Additionally, attempts to paginate through the results using the page parameter have also failed, with the API repeatedly returning the first page.

Steps to Reproduce

1. Using per_page in API Requests

According to the documentation, I should be able to retrieve up to 50,000 results by setting the per_page parameter. However, this does not work as expected.

Example cURL Command:

curl -X GET "https://api.example.com/files?per_page=1000&inbox=true" \
-H "Proxy-Authorization: Bearer TOKEN" \
-u email:password

Expected Behavior:

The API should return up to 1000 files as specified by the per_page parameter.

Actual Behavior:

The API consistently returns only 100 files, irrespective of the per_page value.

Attempting pagination with page parameter

To work around the issue, I tried paginating through the results by incrementing the page parameter manually. However, this also did not work.

curl -X GET "https://api.example.com/files?inbox=true&page=2" \
-H "Proxy-Authorization: Bearer TOKEN" \
-u email:password

Expected Behavior:

This command should return the next set of files.

Actual Behavior:

It returns the same set of 100 files, indicating that pagination is not working as expected.

Additional Information

The issue was consistently reproducible both in the command line using curl in macOS and unix, also programmatically via Go code.

Request

Please investigate and fix the issue with the per_page and page parameters. If there's a specific requirement or limitation we're missing, updating the documentation to clarify the correct usage would also be greatly appreciated.

leondutoit commented 2 weeks ago

I see the docs omitted the fact that you always need to specify the page number with page, when providing the per_page parameter. You should be able to get it to work by doing ?page=0&per_page=1000.

I do think that the per_page should work without specifying page, and will get around to fixing that.

pavelvazquez commented 2 weeks ago

Thank you for your suggestion. I ran the following command to test the per_page and page parameters:

curl -X GET "https://api.example.com/files?page=0&per_page=1000" \
-H "Proxy-Authorization: Bearer" \
-u email:password

Unfortunately, I’m still only receiving 100 files. Is there any additional configuration or context required for this parameter to function correctly?

leondutoit commented 2 weeks ago

Is this running behind a proxy?

pavelvazquez commented 2 weeks ago

It seems like it could be the reason. I'm investigating to confirm if that's the case.