okta/okta-sdk-nodejs

Invalid search criteria when passing queryParameters to listApplications method

Shrirang97 opened this issue · 2 comments

Current behavior

queryParameters = { filter: `user.id+eq+"` + userId + `"`, expand: 'user/' + userId };
oktaClient
    .listApplications(queryParameters)
    .each(oktaApplication => {});

Doc Link: https://developer.okta.com/docs/reference/api/apps/#request-example-14

Behaviour: Giving error as Invalid Search Criteria

Expected behavior

It should return list of applications

Minimal reproduction of the problem with instructions

Try above code with then & catch.

Environment

  • OS: Mac
  • Node.js version: 14.17.1

Code issue

https://github.com/okta/okta-sdk-nodejs/blob/master/src/generated-client.js

Screenshot 2021-08-20 at 3 26 50 PM

qs.stringify method is encoding characters like +, ", \ in query parameters giving output as %2B, %22, %2F.

You should use " " instead of "+" in filter:

queryParameters = { filter: `user.id eq "${userId}"`, expand: `user/${userId}` };

See docs for filter

In this example " " is already encoded into "+" in request URL

Thanks for pointing it out!