arcgis-rest-js
arcgis-rest-js copied to clipboard
searchUsers url path
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?
@tomwayson @mjuniper It looks like the current behavior was introduced in #631 where we used (a) /portals/self/users/search instead of (b) /sharing/rest/community/users - do you know why (a) was used instead of (b)?
This is a good question. Thank you for the details @ak-kemp.
I'm sure the change was driven by Hub needs, but I don't think it's good that we are no longer aligned w/ the other client APIs.
I propose we add a queryUsers() function that does what you did in your above snippet and then clearly document the differences. We should also update this doc to use the new method.