Survey123 Tricks of the Trade: Working with attachments in Microsoft Power Automate

02-25-2021 07:58 PM
Esri Frequent Contributor
4 14 1,636

Survey123 smart forms let you record signatures, photos, annotated images and upload documents into ArcGIS. All of these are stored in ArcGIS as 'attachments'. Microsoft Automate includes a Survey123 connector that helps you access ArcGIS attachments submitted through a smart form.

This blog provides guidance for two common scenarios involving Survey123 attachments and Microsoft Power Automate:

  • Adding multiple Survey123 attachments to an email
  • Uploading Survey123 attachments into Microsoft OneDrive

It is assumed you are already familiar with task automation using Survey123 and Microsoft Power Automate. If so, get started by publishing a survey with an image, signature, file or some other question that uses ArcGIS attachments. Then log into Office 365 and create a new Automated flow with the Survey123 trigger. Follow the instructions below to experiment first hand with Survey123 attachments in Power Automate.

Adding multiple attachments to an email

Survey123 attachments are modeled as an array. In Microsoft Power Automate, you can create an array variable and populate it with Survey123 attachments. Later you can include that array variable in your email.

Immediately after your Survey123 trigger, add the Initialize variable action. We will populate this variable later with the attachments from your survey. Make sure you set the action Type to Array and set a descriptive name. Leave the initial value empty.


 Next, add an HTTP action. This will help us download the attachments. Set the Method to POST. For the URI, you will use the Dynamic content dialog and select the feature attachment URL for your question. In my case, the question with attachments in my survey is called photo, so the dynamic content is feature attachments photo URL.

If you are working with a survey that is shared privately, you will also need to add your token as a query parameter. You can get a valid token from the dynamic content dialog (Portal Info Token).


Survey123 attachments URLs are modeled as an array because a single question in Survey123 can be used
to capture one or many attachments. Microsoft Automate will recognize your photo URL content as
an array and add an Apply to each block automatically.

Immediately after your HTTP module, add an Append to array variable action.

  • For the Name, select the variable you initialized at the top of your flow.
  • For the value, you need to carefully enter a JSON string specifying the ContentBytes and unique Name of the attachments.
  • Start by adding this JSON string

  "ContentBytes": <Your HTTP action Body goes here. Build using an Expression>,
  "Name":<Your feature attachments name goes here. Get from Dynamic Content>

  • Now, replace the ContentBytes and Name values as follows:
    • ContentBytes: Use the Expression tab to write the following expression: body('HTTP}.$content
    • Name: Use the Dynamic content tab to select the feature attachments name property for the question with your attachments. In my case it was feature attachments photos name.


 Make sure you set your JSON value accurately. Do not forget the commas, curly brackets and other things that make JSON be JSON...  Do not forget the comma right after the Body Content!

Add a new Step to send an email.


 The key to setting up the Send an email action is to open the Advanced options panel and click the Switch to input entire array icon.



 You will now be able to use the Dynamic content dialog to select the array variable you setup at the beginning of the flow.


Adding Survey123 attachments to Microsoft OneDrive

Next we will have a look at another common scenario where you might want to backup your files, or host them outside ArcGIS so they can be used with other third party systems.

If you want to upload your attachments into Microsoft One Drive, for example, you can use the Upload file from URL action. For the Source URL property, select from the Dynamic content dialog the feature attachments URL array for the appropriate question in your survey. Remember that if working against a private survey you will also need to add your token to the url (?token=[Portal Info Token]). An apply to each block will be added automatically for you. Now all you need to do is to select the Destination File Path for your file. You can select an existing folder, or even create a new one.


In the example above, I set the Destination File Path using one of the questions in my survey. The value of my question determines the directory in OneDrive where the file will be stored. If the folder exists, it will use it. Otherwise, it will create a new one. This is an interesting concept, as it helps organizing files nicely: by ZIP
code, by case ID, by field team, etc.

A similar approach can be used to upload files into SharePoint, Google Drive or Microsoft Azure File Storage


New Contributor III

@IsmaelChivite - Thanks so much for this resource. We've used power automate with great success and I'm happy to see you helping to advance understanding of this platform coupled with Survey123. What a great combo, thanks!

Esri Frequent Contributor

Hi @ChrisWoodward   Thanks for your comment. Please be aware that the content of this blog applies to an upcoming update of the Survey123 Microsoft Connector. We are a few days behind its planned release and I forgot to delay the scheduled publishing of this article. Ouch!

I will delete this comment once the new connector is updated. The current version of the connector does not expose the token in dynamic content as described in this blog. Only the upcoming update will. We should be able to release the new connector within the next 2 weeks. Fingers crossed!

Occasional Contributor

Can't wait to try the new update! where the attachments is an important elements in our workflow.

Occasional Contributor III

Hi Ismael,

This new update looks fantasitc - can't wait to try it out.

On a related note - I am wondering if there has been a change to webhooks from Power Automate with Survey123.

Previously, I was able to create multiple webhooks per survey in Power Automate. I'd created them in Power Automate and then see multiple webhooks listed in Survey123 > Settings > Webhooks. Now, when I create my second webhook it appears to 'overwrite' the original. 

Is this a change in behavior for Power Automate? 

New Contributor III

@IsmaelChivite when using power automate to upload the photos into the OneDrive application are you simply specifying the folder link within the OneDrive application? Meaning are you simply using a path example like "OneDrive/MyMainFolder/MyProjectFolder/Photos/Feature" or do you need to define the folder using the "encoded" OneDrive values that are all numbers?

Here is an article that shows the numbers I am referring to below (bold text) -


GET https://support.north.local:4443/v5/RestoreSessions/{restoreSessionId}/Organization/OneDrives/{oneDriveId}/Folders/{folderId}


Request Header:

Authorization: Bearer <Access-Token>



200 OK


Response Body:


 "offset": 0,

 "limit": 30,

 "results": [


   "id": "89e2b52a-66e3-4a1a-a088-4655dfbe95d7",

   "name": "F1",

   "createdBy": "System Account",

   "creationTime": "2017-04-04T12:01:49",

   "modifiedBy": "System Account",

   "modificationTime": "2017-04-04T12:01:49",

   "_links": {

    "self": {

     "href": "https://support.north.local:4443/v5/restoresessions/61954db6-7278-4d26-86f7-888bda5a4ec4/organizatio...b3184e77-b95b-45f7-96cc-180a20b61cbd8507931c-4561-4ddf-bc90-411aba44bb39/folders/89e2b52a-66e3-4a1a-a088-4655dfbe95d7"


    "onedrive": {

     "href": "https://support.north.local:4443/v5/restoresessions/61954db6-7278-4d26-86f7-888bda5a4ec4/organization/onedrives/b3184e77-b95b-45f7-96cc-180a20b61cbd8507931c-4561-4ddf-bc90-411aba44bb39"


    "folders": {

     "href": "https://support.north.local:4443/v5/restoresessions/61954db6-7278-4d26-86f7-888bda5a4ec4/organizatio...b3184e77-b95b-45f7-96cc-180a20b61cbd8507931c-4561-4ddf-bc90-411aba44bb39/folders?parentId=89e2b52a-66e3-4a1a-a088-4655dfbe95d7"


    "documents": {

     "href": "https://support.north.local:4443/v5/restoresessions/61954db6-7278-4d26-86f7-888bda5a4ec4/organizatio...b3184e77-b95b-45f7-96cc-180a20b61cbd8507931c-4561-4ddf-bc90-411aba44bb39/documents?parentId=89e2b52a-66e3-4a1a-a088-4655dfbe95d7"





New Contributor

Hello Ismael,

Great write-up! Is it possible to send PDF (.pdf) files as an attachment to an email using Power Automate and Survey123?

I have successfully used Power Automate to send emails with photo (.jpg) and MS Word (.docx) attachments...but we have been unsuccessful using automate to send PDF files.  The PDF files are "corrupt"/unopenable when we receive them via the automate email.

I hope the answer is yes...and you can help.

Thank you

Esri Frequent Contributor

@JamesChan1I am not aware of any limitation in Power Automate in regards with attaching PDF files. This would be more of a question for Microsoft. 

Esri Frequent Contributor

@MichaelBruening  In my own experience I have been able to specify the target folder in OnDrive using human friendly paths.  I was even able to use dynamic content to define the target folder. For example, say you want photos to go into a folder for every user. You can get the username value from userInfo and pass it as a parameter to construct the target path.

Esri Frequent Contributor
New Contributor

Hello Ismael,

Just to clarify...

I am trying to include Survey123 FILE attachments in PDF format in an automated email notification using Power Automate.  I am following the ESRI instructions here:

Those instructions and your write up focus on adding photo attachments. Do you have any information on successfully attaching PDF files to emails from Survey123 using automate?  Does this still sound like a Microsoft limitation?

Thank you

New Contributor III

@JamesChan1I have not tried this within Power Automate as of yet.

However, when working within Integromat I had to make a call through the API for the DOCX file format and then make a call to CloudConvert. This was over a year ago and since then they have released documentation on the Survey123 reporting API.

You should be able to accomplish the attaching of a PDF file using the following API documentation within this blog through an HTTP request. You would use the output format of PDF instead of DOCX.

New Contributor III

@IsmaelChivitethis is great news. Being able to use "human-friendly" paths will definitely make things easier than it was within Integromat. It was a process when trying to reconstructing the OneDrive path using the "computer-friendly" folder ids for my scenarios. 

They'll just be a small transition period of relearning how to manipulate the flows to do what I had accomplished within Integromat. Always fun to learn new ways. 

New Contributor

Hello @IsmaelChivite and @MichaelBruening ,


Thank you for all your help.  I solved my issue.  Turns out that my problem was user error related.  Survey123 and Power Automate work great. Automated emails with attachments is a huge time saver for us.  Using your guidance I successfully atached jpg, docx, AND pdf's. Keep up the good work.

New Contributor

@IsmaelChivite , can you provide an example of uploading file to SharePoint list? I'm having trouble figuring out what value I should provide for the file content parameter of the Add Attachment action?