ArcGIS online no associated attachments error

Jump to solution
04-10-2023 01:36 PM
New Contributor III

I have a Survey123 feature class containing a related table (repeats) with image attachments.  Following this method I was able to get the required URL to show the image in the pop-up.

It returns the correct URL minus the token. I I have shared the feature class publicly, but still get an error when trying to view it. As I said I know the URL is correct as I have compared it the actual one for the attachment.

The calculated one ends FeatureServer/1/8/attachments/1  where the actual logged in one ends with FeatureServer/1/8/attachments/1?token=XXXX

I get the following error when trying to view the image attachment without a token even though it is shared publicly. 

{"error":{"code":404,"message":"Unable to complete operation.","details":["None. This feature has no associated attachments."]}}


Anyone know what the problem might be?  



0 Kudos
1 Solution
3 Replies
MVP Regular Contributor

can you share the arcade expression and image url?

0 Kudos
New Contributor III

Here is the expression :

// first read out the ID of the selected feature (the primary key of the relationship in the parent layer, in this case "globalid")
var id = $feature.globalid;

// access the related table (in this example "relatedtable" is the name of the related table/layer on the map)
var tbl = FeatureSetByName($map, "SCCF_Wildlife_Sightings_view_for_web - observations");

// create a sql expression to query related records based on the primary key and the foreign key for the relationship (in this case, "globalid" from the parent layer, and the "parnetglobalid" from the related layer/table)
var sql = "parentglobalid = '" + id + "'";

// filter the table using the sql expression
var related_data = Filter(tbl, sql);

// return an attribute value from the related record (objectid and id of the first attachment)
for (var row in related_data) {
var reloid = row.objectid;}
var AttachID = First(Attachments(row)).ID

// other url parameters (Part1 is the REST URL of the hosted feature layer
var Part1 = ""
var Part2 = "/attachments/"

//construct the attachment url
var url = Part1 + reloid + Part2 + AttachID

//return the url for the attachment
return url

Here is a link it returns:


That is the correct URL and if I click on it from the attribute table it opens with a token at the end. I have shared the featured class publicly so I don't know why it does not work without the token.



0 Kudos