AnsweredAssumed Answered

How to Access Private Items with REST Search Query?

Question asked by JonM_Coastal on Mar 26, 2020
Latest reply on May 17, 2020 by andrescastillo08

How do I get my REST query to return privately owned (by me) items that are hosted on my organization's ArcGIS Online Portal? My code uses ArcGIS REST JS to create a REST search query. The query successfully returns any items of mine that I have publicly shared, but not the items that are private. I authenticate my credentials in the script using the Identity Manager from the ArcGIS API for JavaScript, and I have no problems accessing my private layers in other ways through the script.

 

Here's the relevant snippet:

// Authentication
var authInfo = new OAuthInfo({
    appId: myAppID,
    popup: false
});

esriId.registerOAuthInfos([authInfo]);

...

// REST JS Query
const query = new arcgisRest.SearchQueryBuilder()
        .match(myUserName)
        .in("owner")
        .and()
        .match("*")
        .in("title")

arcgisRest.searchItems(query);

Again, this query successfully returns my public but not my private items. Is there a way to pass my authentication along with the query? Any help would be appreciated.

Outcomes