I have a feature service with attachments and editing both enabled. Several features have multiple attachments. When I call the queryAttachments() method on this feature layer and pass in an objectId for a feature that has multiple attachments, I only get the first one in the returned data.
This code snippet always returns only the first attachmentInfo but the feature has two attachments. Both attachments are visible in an ArcGIS Online web map that consumes this layer. They are also both visible in the data tab under Content. But again this code only returns the one.
// get all attachments for feature with objectId = 3
const oid = 3;
const attachmentsByObjectId = await layer.queryAttachments({
objectIds: [oid]
});
if (attachmentsByObjectId && attachmentsByObjectId[oid] {
attachmentsByObjectId[oid].forEach(a => {
console.log(a);
});
}
Strangely, if I use Postman to query the exact same feature in the same feature service using the /queryAttachments endpoint, I get the correct number of attachments in the response data.
Some info in this URL is obfuscated for privacy, but the rest call works perfectly.
https://services.arcgis.com/<item>/arcgis/rest/services/<layerName>/FeatureServer/2/queryAttachments
And the above call returns the correct data payload including both attachments:
{
"fields": [
{
"name": "OBJECTID",
"type": "esriFieldTypeOID",
"alias": "OBJECTID",
"sqlType": "sqlTypeOther",
"domain": null,
"defaultValue": null
}
],
"attachmentGroups": [
{
"parentObjectId": 3,
"parentGlobalId": "",
"attachmentInfos": [
{
"id": 1,
"name": "test001.jpg",
"contentType": "image/jpeg",
"size": 3299047,
"keywords": "",
"exifInfo": null
},
{
"id": 2,
"name": "test002.jpg",
"contentType": "image/jpeg",
"size": 488852,
"keywords": "",
"exifInfo": null
}
]
}
]
}
Is there a problem with my JS code, or is there some arbitrary limitation with the JS API where it will only return a single attachment per feature?