Esri/arcgis-rest-js

searchUsers url path

開放

#822 建立於 2021年4月2日

 (2 則留言) (0 個反應) (0 位負責人)TypeScript (126 個分叉)auto 404
enhancementhelp wanted

倉庫指標

星標
 (389 顆星)
PR 合併指標
 (PR 指標待抓取)

描述

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?

貢獻者指南