Query Attachment URL

1675
4
12-24-2020 07:18 AM
DeepUppal
New Contributor II

Hello I’ve seen this question asked but never seen a solution... but: is there a way to query the attachment service URL? 

Example: https://services1.arcgis.com/AGOInstanceName/ArcGIS/rest/services/FeatureName/FeatureServer/3/queryA...

I’d like to query the whole attachment table related to a feature service so an application I’m creating can use the URL’s to pull up the attachments.

I can query and capture the data for the service but I can't capture the attachments that are related without iterating through all the object ids.

Tags (1)
4 Replies
by Anonymous User
Not applicable

There is a returnUrl parameter which returns the attachment URL with the results: https://developers.arcgis.com/rest/services-reference/query-attachments-feature-service-layer-.htm#G...

You still have to append a token if it's a secured service though, otherwise the link won't open.

DeepUppal
New Contributor II

Thanks Michael. But I’ve tried the returnurl parameter. In fact, here is what I tried exactly:

https://services5.arcgis.com/v3DMn7xrRivFMRiU/ArcGIS/rest/services/survey123_86170d7dd0954ceb838466f...

as you can see, I’ve included the returnurl parameter... unfortunately I only get the other data but not the url. 

Any ideas..? 

DeepUppal
New Contributor II

Here is the relavant portion of the query:

/FeatureServer/0/query?returnUrl=true&f=geojson>

by Anonymous User
Not applicable

You have to use the queryAttachments endpoint (links in comments above use the query endpoint) which is layer specific (i.e. you must specify FeatureLayer/<layer_number>/queryAttachments). So something like this works (HTML version): https://services5.arcgis.com/v3DMn7xrRivFMRiU/ArcGIS/rest/services/survey123_86170d7dd0954ceb838466f...

Or this for pjson: https://services5.arcgis.com/v3DMn7xrRivFMRiU/ArcGIS/rest/services/survey123_86170d7dd0954ceb838466f...

0 Kudos