Adding Attachments in Azure DevOps Using Power Automate

In the final part in my mini-series explaining how I extended the Employee Ideas template for Microsoft Dataverse for Teams using Power Automate and Azure DevOps I added some attachments to my user story.

We have to do this in two stages first upload the attachment and then relate it to the work item (user story).

First, let's start with the attached files.

The Employee Idea Files table stores these files and they reside in a column named File.

We'll get the files related to the employee idea and loop through them in the same way as we did for the comments in the previous posts - by using a List Records and an Apply to Each action.

The first action we need to do for each returned file record is to get the contents of the file field. Luckily, there is an action in the Common Data Service (Current Environment) for this called the Get File or Image Content action.

The output of this action is the content of the file in binary format.

Next, we need to upload this content as an attachment in Azure DevOps. We do this by sending an HTTP request With the following parameters -

Note in particular the numbered properties

  1. The project name

  2. The name of the column from the employee ideas file table

  3. The output of the get file action discussed earlier converted to a base64 string (see image below)

Before moving onto the next step, you should run the Flow and take note of the output received from uploading the attachment. It will help us in the next step.

Snag_21305b62.png

We will need the URL from the output so let's parse the JSON of the HTTP request. We can generate the schema from the output we took note of earlier.

Snag_213189b0.png

Now that we have the URL of the attachment, we can use another HTTP request to associate it to the work item.

Snag_21326a0e.png

Note, that you must add the correct header to this request.

Snag_21343037.png

Now that the files are uploaded we follow the same process for the cover image. The employee ideas table stores this image in the cover image column.