AnsweredAssumed Answered

Fetching Attachments from hosted FeatureServices REST endpoint

Question asked by akajanus-esristaff Employee on Mar 7, 2013
Latest reply on Mar 8, 2013 by KHassen-esristaff
Hi,

This post has 2 things, first one interesting scenario how the REST endpoint is working and second part some questions how to work with the Attachments.

I have hosted FeatureService with attachments enabled in the ArcGIS Online and I use direct REST query to add/update them from my Windows Service. I have noticed that the feature part of REST doesn't affect the attachment query at all and I can access all attachments from any feature endpoint.

The case here is that we have published Feature Service that contains some traffic cameras around Finland and we are adding / updating the images to the Features as a attachments. At background I have Windows Service that does some SOAP calls to another system were we get the updated images in not-so-easily-used-in-the-ArcGIS-systems.

--- Test case ---

FeatureService :
http://services.arcgis.com/4PuGhqdWG1FwH2Yk/arcgis/rest/services/Mittauspisteet/FeatureServer/0

Access to Feature:
http://services.arcgis.com/4PuGhqdWG1FwH2Yk/ArcGIS/rest/services/Mittauspisteet/FeatureServer/0/44

List of Attachments with Feature 44:
http://services.arcgis.com/4PuGhqdWG1FwH2Yk/ArcGIS/rest/services/Mittauspisteet/FeatureServer/0/44/attachments?f=html&token=

Feature 44 has only 1 attachment with ID = 32.

CASE 1:
Access to Attachment with ID = 32

http://services.arcgis.com/4PuGhqdWG1FwH2Yk/ArcGIS/rest/services/Mittauspisteet/FeatureServer/0/44/attachments/32

--> I get correct Attachment

CASE 2:
Access to Attachment with ID = 33

http://services.arcgis.com/4PuGhqdWG1FwH2Yk/ArcGIS/rest/services/Mittauspisteet/FeatureServer/0/44/attachments/33

--> I get Attachment that is assigned to Feature 45

CASE 3:
Access to Attachment with ID 32 but in context of Feature 45

http://services.arcgis.com/4PuGhqdWG1FwH2Yk/ArcGIS/rest/services/Mittauspisteet/FeatureServer/0/45/attachments/32

--> I get same attachment that I get in case 1

-----------------------------------------

CONCLUSION:

The Feature specified in the URL actually doesn't do anything and I can access to all Attachments in context of any existing feature.

-----------------------------------------

QUESTIONS:

I haven't tested this with service that is hosted in the ArcGIS Server but do you know if it works the same and is this the behavior how it should be working? At least from my perspective, if we are using the Feature in the structure, then the query should only affect attachments that are associated with that.

Can attachments be accessed with some other Identifier than it's Id? Like with the uploaded name directly from the REST. In my case, I wouldn't like to make AttachmentInfo call for every Feature. As a round work, we have the Attachment id stored in the feature by itself so we can construct the Image Url directly from the information known. In our case, each Feature should have only 1 attachment that is updated in the background. There are Features that doesn't have any attachments yet so we cannot directly relay that Feature ObjectId == Attachment Id even if we add Attachment in order. Any thoughts on this?

Outcomes