Download Attachment from AGOL Hosted Feature Layer
Does anyone have any experience downloading an attachment from an AGOL hosted feature layer as part of a workflow?
I am able to run the Query Attachment Infos activity to see the attachment id, file type, and file size; but I cannot get at the actual file data itself to download and save. If this were an ArcGIS Server feature service it looks like I could format the REST API request URL to download the attachment using the attachment id, but that seems to get a little trickier with AGOL and generating a token and passing that along in the web request.
-
For posterity's sake, I've got a shell of a solution in place, with the rough outline below:
- Use the Get Workflow Inputs activity to get the layer from the context item
- Use the Get Layer activity to retrieve the URL for the layer from the context item
- Utilize the Query Attachment Infos activity to get the id for the attachment(s)
- Run a server workflow to retrieve an AGOL token
- Construct the REST API request URL with a combination of the layer url/attachment id/token
- Use the Send Web Request activity with the constructed URL
- Run a server workflow to convert the response from the web request to bytes and create the file
Seems like there should be an easier process... but alas, this does the trick :-).
0 -
Thanks for outline Brian, did you have to include something in the header? I assume this is to convert the response from json to bytes?
0
Please sign in to leave a comment.
Comments
2 comments