Open COV-GIS opened 4 years ago
Setting a custom portal with IRequestOptions via setDefaultRequestOptions() is not working for me.
can you share a repro case?
Not at this time. But...
setDefaultRequestOptions({
portal: 'https://<URL>/portal/sharing/rest/'
});
searchItems('ownerfolder: ea19...91ac').then();
// request made to arcgis.com
searchItems({
q: 'ownerfolder: ea19...91ac',
portal: 'https://<URL>/portal/sharing/rest/'
}).then();
// request made to custom portal url
And any custom request options are inaccessible. https://github.com/Esri/arcgis-rest-js/blob/master/packages/arcgis-rest-request/src/request.ts#L15
If time permits I may PR getDefaultRequestOptions()
and getFolderItems()
.
thanks!
If time permits I may PR
getDefaultRequestOptions()
.
something like that is actually exactly what's needed to fix the bug you found. we have quite a few methods in the portal package that call the utility function getPortalUrl()
internally to attempt to dig the correct portal out of the authentication session if necessary prior to request()
being called.
if request
exported a function that exposed custom defaults instead of burying them in an internal variable, getPortalUrl() could honor them as well.
I messed around with this a bit. Setting a default portal
is being overridden by something in the portal package when mixing all the bits and pieces into a request. And only when not authed. I'm not going to have time to investigate further. I suspect using portal package methods w/o auth is rare except to search content perhaps, and adding the portal
param to searches is an easy enough fix. So closing this issue.
Reopening this. I think that anonymous requests with a portal
set with setDefaultRequestOptions
should still work since people might use this to access public data on their own portals.
Thanks @patrickarlt for looking into it.
I noticed setDefaultRequestOptions
sets defaults instead of mixing in.
I tried mixing in setDefaultRequestOptions
with defaults thinking there might be a scenario where different defaults might be set at different points. Maybe? Added a getDefaultRequestOptions
method and tests, but caused mass failure. Kinda beyond my role, and aside from the portal
issue those top level design decisions probably best left to the maintainers.
Setting a custom portal with IRequestOptions via
setDefaultRequestOptions()
is not working for me; making calls to arcgis.com instead of the custom portal. Looks like it should be mixing it in: https://github.com/Esri/arcgis-rest-js/blob/master/packages/arcgis-rest-request/src/request.ts#L37-L47 and https://github.com/Esri/arcgis-rest-js/blob/master/packages/arcgis-rest-request/src/request.ts#L195. I've set otherIRequestOptions
withsetDefaultRequestOptions()
to test and they are being successfully mixed in. Is this not the proper method for setting a custom portal? Or is there something I'm missing in the portal package to do so? Or?And a mostly unrelated question for you Esri folks that work with portal a lot. Is there a simple query to get items by folder id? I looked at how portal content fetches items for a folder. It makes several pretty complex queries and ultimately queries the item ids to display. I'm hoping there's an easier way but the lack of a function in the portal package has me thinking not. Thanks.Edit:
ownerfolder: <ID>
works just fine if you remember to pass auth with the request.