web
You’re offline. This is a read only version of the page.
close
Skip to main content

Notifications

Announcements

Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Automate / Upload attachments fro...
Power Automate
Answered

Upload attachments from MS Forms to Azure DevOps Board work item

(0) ShareShare
ReportReport
Posted on by

Hi

 

I have an MS form where the user has to upload a file in one of the questions. 

I was able to create a flow that generates a work item when the form is submitted.

 

shsharma14_0-1657147060104.png

 

But how do I get the attachments as well from forms into the work item?

I know the attachments get stored in one drive and we can get contents from one drive and then send a HTTP request to Azure DevOps but I am confused about the flow.

 

Can anyone please help me with the steps?

 

Categories:
I have the same question (0)
  • Verified answer
    v-bofeng-msft Profile Picture
    on at

    Hi @shsharma14 ,

     

    You could this way to get the file content:

    vbofengmsft_0-1657249278463.png

     

    Best Regards,

    Bof

     

  • KelvinRHC Profile Picture
    19 on at

    Hi @v-bofeng-msft I am trying to replicate your advice above in my own flow however I'm not seeing the same Field 'id' as yourself. I copied your expression into the 'Get file content' and I also tried looking up an 'id' field however the only available one which appeared for me in the list objects was 'Response Id'. Can you tell me where I'm going wrong here?

    KelvinRHC_0-1665577784094.png

    Many thanks,

    Kelvin

     

  • ersanbil Profile Picture
    6 on at

    this is not a good answer even its marked as solution.

     

    please provide step-by-step flow details, this solution provides only how to get necessary file parameters from one drive, after that there is no mention to post is as azure devops attachments and relate it with the created workitem.

     

    i'd be glad if anyone provides an end-to-end solution for this.

    thanks

  • Rachy_2023 Profile Picture
    5 on at

    Did we get a solution for this?

  • KelvinRHC Profile Picture
    19 on at

    This 100% was never resolved. I was pretty clear on that based on my responses and I never marked it as resolved myself. Are there any admins watching this page who know how to mark it as "not resolved"?

  • KelvinRHC Profile Picture
    19 on at

    Nope never resolved (not even close). Someone marked it as resolved even though I never accepted the solution and I'm not able to change that status.

  • Sanna2499 Profile Picture
    6 on at

    Hi,

     

    Has anyone found a solution to this problem?

    I am also trying to upload MS Forms attachments to the Azure DevOps work item.

  • Ratheeshvenu Profile Picture
    Microsoft Employee on at

    I am also trying to upload MS Forms attachments to the Azure DevOps work item but no luck yet. The below flow works and can get all the fields but except the attachment. Any suggestions?

    Ratheeshvenu_0-1684786783219.png

     

  • lupompei Profile Picture
    Microsoft Employee on at

    Same here. Need to solve how to include the attachments in Azure DevOps from Forms. I have tried the Send an Http request action, however my power user has no access to the one drive. I could not test if works. 

    lupompei_0-1690207783174.png

     

  • NiclasWJ Profile Picture
    19 on at

    EDIT:
    Below only worked if an attachment was actually uploaded but failed if no upload was made.
    To fix this, we add a condition based on length on the actual form output that we are using and put the "Parse JSON" and "For Each Attachment" within that "If yes".

     

    The condition should be " "0" is not equal to "length(body('Get_response_details')?['the_form_question'])" "

     

    NiclasWJ_0-1698997766900.png

     



    Hi @ersanbil @Ratheeshvenu @shsharma14 @KelvinRHC 

    Recently I managed to get this working and since I do not see this "solution" elsewhere in the community I thought of posting it.
    This solution adds ALL attachments for me.

     

    I am no Power Automate veteran so have that in mind, and sorry in advance for the mix of Swedish and English in the samples below.

    NiclasWJ_0-1698658631134.png

     

     

     

    NiclasWJ_1-1698658631135.png

     

    NiclasWJ_2-1698658631135.png

     

     

     

    Explanation:

    1. "Parse the JSON" with the question including the upload attachment from the MS Forms "Get Response Details"

    Scheme:

     

    {
     "type": "array",
     "items": {
     "type": "object",
     "properties": {
     "name": {
     "type": "string"
     },
     "link": {
     "type": "string"
     },
     "id": {
     "type": "string"
     },
     "type": {},
     "size": {
     "type": "integer"
     },
     "referenceId": {
     "type": "string"
     },
     "driveId": {
     "type": "string"
     },
     "status": {
     "type": "integer"
     },
     "uploadSessionUrl": {}
     },
     "required": [
     "name",
     "link",
     "id",
     "type",
     "size",
     "referenceId",
     "driveId",
     "status",
     "uploadSessionUrl"
     ]
     }
    }

     

    2. "For Each" I then:

    3. "OneDrive for Business - Get File Content by Path" where the content is the path such as apps/Microsoft Forms/{form name}/{question}/@{items('For_Each_Attachment')['name']} - This to get the content of all files as Base64, Name is from the first Parse JSON

    4. "Compose" with the expression below - This is to retrieve only the Base64 content from the Get File Content which contains other information as well.

     

    outputs('Get_File_Content_by_Path')?['body/$content']

     


    5. "Send a HTTP request to Azure DevOps - Send Attachment to DevOps" with:

    POST

    URL = {project}/_apis/wit/attachments?filename=@{items('For_Each_Attachment')['name']}&api-version=7.1

    Content-Type = application/octet-stream

    Body = Output of "Compose"

    Set body as Base64

    This is to send the attachment into DevOps, this does not link it to any workitem. Name is from the first Parse JSON.

    6. "Parse JSON" with the output from "Send Attachment to DevOps" as content and the following scheme:

     

    {
     "type": "object",
     "properties": {
     "id": {
     "type": "string"
     },
     "url": {
     "type": "string"
     }
     }
    }

     

    This is so we can know what the URL is of the attachment we want to attach later on.

     

    7. "Send a HTTP request to Azure DevOps - Add attachment" with:

    PATCH

    URL = {project}/_apis/wit/workitems/@{outputs('Create_change_request')?['body/id']}/?api-version=7.2-preview

    @{outputs('Create_change_request')?['body/id']} is the ID of your workitem which is created before in the flow

    Content-Type = application/json-patch+json

    Body = ( url = "url" from lst Parse JSON ) ( name = name from first Parse JSON )

     

    [
    {
    "op": "add",
    "path": "/relations/-",
    "value":
    {
    "rel": "AttachedFile",
    "url": "@{body('Parsa_JSON_2')?['url']}",
    "attributes": 
    {
    "comment": "Automatic attachment upload",
    "name":"@{items('For_Each_Attachment')['name']}"
    }
    }
    }
    ]

     

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Forum hierarchy changes are complete!

In our never-ending quest to improve we are simplifying the forum hierarchy…

Ajay Kumar Gannamaneni – Community Spotlight

We are honored to recognize Ajay Kumar Gannamaneni as our Community Spotlight for December…

Leaderboard > Power Automate

#1
Michael E. Gernaey Profile Picture

Michael E. Gernaey 525 Super User 2025 Season 2

#2
Tomac Profile Picture

Tomac 324 Moderator

#3
abm abm Profile Picture

abm abm 232 Most Valuable Professional

Last 30 days Overall leaderboard