Esri/arcgis-rest-js

searchUsers url path

Open

#822 opened on Apr 2, 2021

 (2 comments) (0 reactions) (0 assignees)TypeScript (126 forks)auto 404
enhancementhelp wanted

Repository metrics

Stars
 (389 stars)
PR merge metrics
 (PR metrics pending)

Description

The Content management chapter in the developer guide shows the reader how to access items, users, and groups in the portal using RestJS, JavaScript, Python, and iOS APIs.

One of the snippets shows the reader how to search for a user.

The REST call for that query uses the following url: https://www.arcgis.com/sharing/rest/community/users, and an example of the response one would get can be seen here.

The JavaScript API, also uses that path for its queryUsers() method, as well as Python. However, the userSearch method in Rest JS is not functionally equivalent. It uses a different url: /portals/self/users/search.

When I create the following query:

const authentication = new UserSession({ // ArcGIS account credentials
  token: "ACCESS_TOKEN"
});

    arcgisRest.searchUsers({
       q: "Jsmith",
       authentication: authentication
     }).then((response)=>{
      console.log(response);
   })

I don't get the same results because, I think, it is searching within my organization. To get around this, I had to just make a raw request to the REST API:

const authentication = new UserSession({ // ArcGIS account credentials
  token: "ACCESS_TOKEN"
});

request("https://www.arcgis.com/sharing/rest/community/users", {
  authentication: authentication,
  params: { q: "JSmith"}
}).then((response)=>{
  console.log(response)
});

Is there a reason why the userSearch method uses the portals/self/users/search url? Is there a way, besides using the request method, to access the /sharing/rest/community/users url instead?

Contributor guide