clowder-framework / clowder

A data management system that allows users to share, annotate, organize and analyze large collections of datasets. It provides support for extensible metadata annotation using JSON-LD and a distribute analytics event bus for automatic curation of uploaded data.
https://clowderframework.org/
University of Illinois/NCSA Open Source License
34 stars 17 forks source link

api/datasets/{id}/downloadFolder endpoint "Cannot parse parameter folderId" when "?key=" query used #356

Closed taywll252 closed 2 years ago

taywll252 commented 2 years ago

Describe the bug I was attempting to use the api/datasets/{id}/downloadFolder endpoint. I used the URL path:

/api/datasets/{id}/downloadFolder?folderId={id}?key={apiKey}

I received a "status":"bad request" and "message":"Cannot parse parameter folderId" in return.

The request worked when I opted to use the X-API-Key in the header instead of the ?key= query parameter.

I noticed in the documentation that the ?key= parameter is deprecated in favor of using the header. However, the message says the folderId parameter couldn't be parsed, so something else seems to be going on.

To Reproduce Steps to reproduce the behavior:

  1. Select a folder ID and dataset ID to download using the api/datasets/{id}/downloadFolder endpoint
  2. Attempt to execute while using the ?key= API key query parameter
  3. See error
  4. Attempt to execute while NOT using the ?key= query parameter, but the X-API-Key header
  5. Works as expected

Expected behavior Zip folder of the selected folder ID from the selected dataset ID should be downloaded when using the ?key= API key query parameter (although deprecated).

Screenshots Example request error: clowder_downloadFolder_error

Desktop (please complete the following information):

Additional context Clowder Version: 1.20.1#854 branch:master sha1:86ba0e36a38aed057bd5ca104495c5f3af67613a

robkooper commented 2 years ago

The url is invalid. The url is made up of the host, path and query string. The query string starts with ? and each part is separated with &. In your example you have two ? in the query. The correct syntax is: /api/datasets/{id}/downloadFolder?folderId={id}&key={apiKey}

taywll252 commented 2 years ago

@robkooper Thanks for the quick reply. I see that obvious mistake in path syntax now. I was thrown off by the error message pointing to the "folder ID" parameter as the issue and seeing that key= is deprecated. Thankfully just an easy fix on my side.