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

Announcements

News and Announcements icon
Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Automate / Adding the attachments...
Power Automate
Unanswered

Adding the attachments to Azure DevOps work item in "Create a Work item" step

(2) ShareShare
ReportReport
Posted on by Microsoft Employee

Hi ,

 

Is there a way to attach a certain file from email directly to the attachments section in the User story of Azure DevOps, I'm currently having a flow that creates a work item whenever tehre is a new email but can't able to process the attachments linked to it. I need those attachments in the user story itself. Can somebody help me??

Categories:
I have the same question (0)
  • yashag2255 Profile Picture
    24,769 Super User 2024 Season 1 on at

    Hi @Anonymous 

     

    Currently adding an attachment as a direct action is not supported in flow. However, you can refer to the thread below where a workaround has been suggested for creating the attachments:

    https://powerusers.microsoft.com/t5/Building-Flows/Create-work-item-at-Azure-DevOps-from-an-email-with-attachments/td-p/176019

     

    You can post an idea here to include this as a feature in flow:

    https://powerusers.microsoft.com/t5/Flow-Ideas/idb-p/FlowIdeas

     

    Hope this Helps!

    If this reply has answered your question or solved your issue, please mark this question as answered. Answered questions helps users in the future who may have the same issue or question quickly find a resolution via search. If you liked my response, please consider giving it a thumbs up. THANKS!

  • TheSwilliam Profile Picture
    40 on at

    Make sure you name everything the exact same thing as what I have if you are copying and pasting from here. You will need to add in your organization name.

    The schema is:

    First part flow.PNG

     

     

    {
     "type": "object",
     "properties": {
     "Id": {
     "type": "string"
     },
     "Name": {
     "type": "string"
     },
     "ContentBytes": {
     "type": "string"
     },
     "ContentType": {
     "type": "string"
     },
     "Size": {
     "type": "integer"
     }
     }
    }

     

     

     

    Then

    Post the attachment.PNG

    the binary function is: 

     

     

     

    binary(body('Parse_JSON')?['ContentBytes'])

     

     

     

    Make sure you change the areaPath in the relative URI. I left it as mine which is just Portal.
    Code snippet for the step above: 
    {
        "inputs": {
            "host": {
                "connection": {
                    "name""@parameters('$connections')['shared_visualstudioteamservices']['connectionId']"
                }
            },
            "method""post",
            "body": {
                "Method""POST",
                "Headers": {
                    "Content-Type""application/octet-stream"
                },
                "Body""@{binary(body('Parse_JSON')?['ContentBytes'])}",
                "IsBase64"true
            },
            "path""/httprequest",
            "queries": {
                "account""YourOrganization"
            },
            "authentication""@parameters('$authentication')"
        },
        "metadata": {
            "flowSystemMetadata": {
                "swaggerOperationId""HttpRequest"
            }
        }
    }
    Then
    compose.PNG
    The 'Body' in 'Compose' is the body that you will get from the Http Post which I have named 'Post Attachment'
    The 'url' is actually an output function: 

     

     

     

    outputs('Compose')['url']

     

     

     

    The outputs function is getting the url property from the response json from Post Attachment.
    Code snippets for the steps above:
    Compose:
    {
        "inputs""@body('Post_Attachment')"
    }
    Compose 2
    {
        "inputs""@outputs('Compose')['url']"
    }
     

    Then

    Final 3.PNG
    The 'Id' is the work Item Id that gets returned form the create a new work item step. 
    The 'Outputs' is from 'Compose2'. It should pop up for you on the add dynamic content popup.  
    Code snippet for the step above:
    {
        "inputs": {
            "host": {
                "connection": {
                    "name""@parameters('$connections')['shared_visualstudioteamservices']['connectionId']"
                }
            },
            "method""post",
            "body": {
                "Method""PATCH",
                "Headers": {
                    "Content-Type""application/json-patch+json"
                },
                "Body""[\n  {\n    \"op\": \"add\",\n    \"path\": \"/relations/-\",\n    \"value\": {\n      \"rel\": \"AttachedFile\",\n      \"url\": \"@{outputs('Compose_2')}\",\n      \"attributes\": {\n        \"comment\": \"Spec for the work\"\n      }\n    }\n  }\n]",
                "IsBase64"false
            },
            "path""/httprequest",
            "queries": {
                "account""YourOrganization"
            },
            "authentication""@parameters('$authentication')"
        },
        "metadata": {
            "flowSystemMetadata": {
                "swaggerOperationId""HttpRequest"
            }
        }
    }

     

     

    Hope this helps!

  • TheSwilliam Profile Picture
    40 on at

    Make sure you name everything the exact same thing as what I have if you are copying and pasting from here. You will need to add in your organization name.

    First part flow.PNG

    The schema is:

     

    {
    "type": "object",
    "properties": {
    "Id": {
    "type": "string"
    },
    "Name": {
    "type": "string"
    },
    "ContentBytes": {
    "type": "string"
    },
    "ContentType": {
    "type": "string"
    },
    "Size": {
    "type": "integer"
    }
    }
    }

     

    Then
    Post the attachment.PNG
    the binary function is: 

     

    binary(body('Parse_JSON')?['ContentBytes'])

     

    Make sure you change the areaPath in the relative URI. I left it as mine which is just Portal.
     
    Then
    compose.PNG
    The 'Body' in 'Compose' is the body that you will get from the Http Post which I have named 'Post Attachment'
    The 'url' is actually an output function: 

     

    outputs('Compose')['url']

     

    The outputs function is getting the url property from the response json from Post Attachment.
     
    Then
    Final 3.PNG
    The 'Id' is the work Item Id that gets returned form the create a new work item step. 
    The 'Outputs' is from 'Compose2'. It should pop up for you on the add dynamic content popup.  

    Hope this helps!

  • Community Power Platform Member Profile Picture
    Microsoft Employee on at

    @TheSwilliam 

    Thank you for the solution. I implemented your solution and the flow did run successfully, but the file wasn't attached to the work item in Azure DevOps. Can you please advise?

  • TheSwilliam Profile Picture
    40 on at

    Hi @Anonymous,

     

    Can you send screen shots of your two Http request actions? You have to make sure the first is a POST with the header "Content-Type""application/octet-stream". The second one has to be a PATCH with the header  "Content-Type": "application/json-patch+json" 

  • Community Power Platform Member Profile Picture
    Microsoft Employee on at

    @TheSwilliam 

    Thank you for your quick response.

    Please find attached the screenshots:

    johns4Upmc_0-1599074442994.png

     

     

    johns4Upmc_1-1599074584001.png

     

  • TheSwilliam Profile Picture
    40 on at

    @Anonymous everything looks good there. Do you mind sending the binary function and the compose functions. You can just send the code. Also what type of files are you sending/how big are they? You may need to change your upload type from simple to chunked. Here is the link if you'd like to read about it. 

    https://docs.microsoft.com/en-us/rest/api/azure/devops/wit/attachments/create?view=azure-devops-rest-6.0#start-a-chunked-upload

  • Community Power Platform Member Profile Picture
    Microsoft Employee on at

    @TheSwilliam 

     

    johns4Upmc_0-1599075680979.png

    Binary Function : 

    binary(body('Parse_JSON')?['ContentBytes'])
  • Community Power Platform Member Profile Picture
    Microsoft Employee on at

    @TheSwilliam The file is a normal .txt or .pdf file

  • TheSwilliam Profile Picture
    40 on at

    @Anonymous I see your issue. You are grabbing the wrong body in your first compose. You need to grab the body that the first http request generates. 

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

Introducing the 2026 Season 1 community Super Users

Congratulations to our 2026 Super Users!

Kudos to our 2025 Community Spotlight Honorees

Congratulations to our 2025 community superstars!

Leaderboard > Power Automate

#1
Haque Profile Picture

Haque 58

#2
David_MA Profile Picture

David_MA 53 Super User 2026 Season 1

#3
Expiscornovus Profile Picture

Expiscornovus 36 Most Valuable Professional

Last 30 days Overall leaderboard