I have successfully created a Microsoft Form and used Power Automate to create a Work Item in the desired Area Path of my ADO instance.
The issue I’m having is understanding how to now get any attachments captured on the form attached to the Work Item. I’ve read through a number of posts on the topic, via the web, and have asked Co-Pilot, but I’m still having difficulty understanding what needs to be done and how to do it.
Been trying to digest all the answers I’ve come across, but each answer seems to be a bit different.
Trying to follow below from Co-Pilot, but I do not see how I get the AttachmentID from the 1st step. Nor am I sure what I need to do with the Attachment item of the forms response, if anything. It all seems SO MUCH more complicated than it should be.
FROM Co-Pilot:
Create Attachment (POST):
Use the “Send an HTTP request to Azure DevOps” action.
Set the HTTP method to POST.
Construct the URL to create an attachment for the work item. For example:
https://dev.azure.com/{organization}/{project}/_apis/wit/attachments?fileName=myattachment.txt&uploadType=Simple&api-version=6.0
In the request body, provide the attachment details. You can upload the attachment directly or provide a link to the file.
JSON
{
“fileName”: “myattachment.txt”,
“uploadType”: “Simple”,
“content”: “base64-encoded content of the attachment”
}
This step creates the attachment.
Upload Attachment (PATCH):
Once you have the attachment ID from the previous step, use the “Send an HTTP request to Azure DevOps” action again.
Set the HTTP method to PATCH.
Construct the URL to update the work item with the attachment. For example:
https://dev.azure.com/{organization}/{project}/_apis/wit/workitems/{workItemId}?api-version=6.0
In the request body, add the attachment ID to the work item’s “System.AttachedFiles” field.
JSON
{
“op”: “add”,
“path”: “/fields/System.AttachedFiles”,
“value”: [
{
“id”: “{attachmentId}”
}
]
}
This step associates the attachment with the work item.
Remember to replace placeholders like {organization}, {project}, {workItemId}, and {attachmentId} with actual values from your environment. Adjust the field names and attachment details as needed for your specific use case.