Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Query by metadata has incorrect options #877

Closed
4 tasks done
swanysimon opened this issue Apr 28, 2024 · 1 comment
Closed
4 tasks done

Query by metadata has incorrect options #877

swanysimon opened this issue Apr 28, 2024 · 1 comment
Assignees
Labels

Comments

@swanysimon
Copy link

Description of the Issue

The query by metadata function is not correct and will always result in a 400 Bad Request if query_parameters are supplied. Specifically, the query_parameters options should be query_params, and order_by should be optional. In addition there are missing options: limit and marker.

API Reference: https://developer.box.com/reference/post-metadata-queries-execute-read/

Steps to Reproduce

An example:

    const options = {
      fields: ["id", "name", "sha1"],
      query: "myMetadataIdField = :id",
      query_parameters: {id: "my_special_id"},
      order_by: {},
    };
    return this.client.metadata.query(
      "enterprise_scope.metadataTemplateKey",
     "123",
      options,
    );

And you receive a:

Error: Unexpected API Response [400 Bad Request | ...] invalid_query - Parameter id: no value provided

(I actually got this error after removing the order_by field because before that, you don't even get a reason for why the request was bad, you just get a 400)

Expected Behavior

To receive a 200 response and my matching files.

Workaround

Forcibly ignore the type mismatch.

    const options = {
      fields: ["id", "name", "sha1"],
      query: "myMetadataIdField = :id",
      query_params: {id: "my_special_id"},
    };
    return this.client.metadata.query(
      "enterprise_scope.metadataTemplateKey",
     "123",
      // @ts-expect-error: option type definition for metadata query is incorrect
      options,
    );

Error Message, Including Stack Trace

I'd rather not redact, and this seems pretty straightforward.

Screenshots

n/a

Versions Used

Node SDK: 3.1.1 and 3.5.0

@arjankowski
Copy link
Contributor

Hi @swanysimon,
We've just released the new version of box-node-sdk, 3.5.1, with the fix to the bug you mentioned.

Regards,
Artur

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

7 participants