fusionauth-typescript-client icon indicating copy to clipboard operation
fusionauth-typescript-client copied to clipboard

searchUsersByIds Badly formats the query, resulting in an error

Open Antonhansel opened this issue 1 year ago • 1 comments

Hello,

It seems that SearchUsersByIds isn't implemented properly in the SDK, here is the implementation

  searchUsersByIds(ids: Array<string>): Promise<ClientResponse<SearchResponse>> {
    return this.start<SearchResponse, Errors>()
        .withUri('/api/user/search')
        .withParameter('ids', ids)
        .withMethod("GET")
        .go();
  }f

When called like this:

    const { response: { users } } = await fusionAuthClient.searchUsersByIds(localUsers.map((user) => String(user.id)));

The following error is returned:

{
  "statusCode": 400,
  "exception": {
    "fieldErrors": {
      "ids": [
        {
          "code": "[couldNotConvert]ids",
          "message": "Invalid"
        }
      ]
    },
    "generalErrors": [
      {
        "code": "[invalid]",
        "message": "You must specify either the [ids], [queryString], or [query] property. If you are continuing a search, you must include the [nextResults] property."
      }
    ]
  }
}

The expected format from the API is this (unconventionnal, but it is what it is)

localhost:9011/api/user/search?ids=id1&ids=id2

Is there a workaround with another method or should I use a direct API call ?

Antonhansel avatar Dec 21 '23 18:12 Antonhansel