Power Automate - Create Azure DevOps WorkItem and Attachments
Vložit
- čas přidán 20. 12. 2022
- This video explains how to create a work item in Azure DevOps and add attachments.
Upload attachments
/_apis/wit/attachments?filename=@{items('Apply_to_each')?['name']}&api-version=5.1
Content-Type
application/octet-stream
Link WorkItem with attachments
/_apis/wit/workitems/@{outputs('Create_a_work_item')?['body/id']}/?api-version=5.1
Content-Type
application/json-patch+json
[
{
'op': 'add',
'path': '/relations/-',
'value': {
'rel': 'AttachedFile',
'url': '@{body('Parse_JSON')?['url']}',
'attributes': {
'comment': 'Bug details',
'name':'@{items('Apply_to_each')?['name']}'
}
}
}
]
Microsoft Documentation
learn.microsoft.com/en-us/res...
For multiple attachments please see this.
powerusers.microsoft.com/t5/B...
Update:
Some of you getting errors regarding attachments cannot open. I believe its a bug.
So do the following:
Change the version from 5.1 to 5.0
/_apis/wit/attachments?filename=@{items('Apply_to_each')?['name']}&api-version=5.1
Then under the body use expression
binary('here map the email attachment content bytes')
Set the Body is Base64 to Yes
This should work. I have tested this.
Thanks
Thank you , very helpful
Thanks a lot
Thank you so much 👌
Most welcome 😊
This is so helpful
Thanks a lot
really helpful
Thanks Shubham
Do you know of a way to add an attachment to a task in DevOps IF you are using a HTTP request and not a "Create Item" action and not using email? (I'm using only a send http request to create a new task using JSON and API bypass, but I can't figure out how to add an attachment).
Hi Mark
I haven't explored that yet.
Thanks
Very helpful! Thanks! I am using this with a Microsoft Form. Flow runs without errors but the attachments can't be opened. Any ideas?
See in my video details. I have mentioned a fix for this.
can someone help me? I am still getting the corrupted files only.
I have a trigger comming from a powerapp getting the file
The code in the body is:
binary(triggerBody()?['file']?['contentBytes'])
base64 is set to yes.
Can anyone help me?
Hi there, thank you for this tutorial it is very helpful! I'm a little stuck on the bug fix suggestion to use the expression
binary('here map the email attachment content bytes')
Could you go into bit more detail on how you map the email attachment content bytes?
Thank you!
Hi
Thanks for your kind comments. So thats the expression I am talking about. I need to see you flow. I could offer a screenshare help. You can connect me via teams. My contact email is under the channel about section.
Thanks
Excelent. Ihave a question. How can I get the name an other properties of files attached of a work item in azure, export all of this in an excel, just with a flow in power automate?
Hi
So do you want to get all the files attached from all the work item? Also please mention which are the specific properties you looking for?
Thanks
Hello, can you help me with a project.
I need to use power automate to send reminder emails to a particular email if a client's medical update is due. We have an excel sheet that contains each client's due date and their emails to notify them. How do I do it?
Hi
I have made a video based on your request. Here it is.
czcams.com/video/puR70yQMJKE/video.html
Thanks
This is awesome, but was wondering if you had a video about integrating Service Now with DevOps using Power Automate? :)
Hi @pujaladva2707
I don't have a subscription for service now. Do you need license for this? If you can provide me a demo link I could have look at this.
Please let me know.
Thanks
This wonderful but I am facing issue in last action stating : the request indicated a Content-Type of "application/json" for method type "PATCH" which is not supported Valid content types for this method are: application/json-patch+json
Hi Sowmya
Check your mapping properties. Make sure you have the right schema names.
Thanks
Thank your for the helpful video. I find that on trying to download and open the attachments from the newly created work item, it appears the attachments are corrupted and do not open, irrespective of the type of attachment. Also any inline images (email body) are not loading. Please advise ..
Hi
Check the email connector properties whether you enabled the attachments to yes. Please let me know.
Thanks
@@abm4975 - I have ‘Include Attachments’ as Yes .. and ‘Only with Attachments’ as No. Is this what you are referring to? The attachments are appearing in the new work item (right files, size etc.) but when you try to view / download the files it says content is corrupted.
Hi
Looks like you got the right settings. What's the file type (pdf, .xlsx, docx). You could contact me via my channel about section. I could have a look via screenshare. If not please post a screenshot in Power Automate community and tag me as @abm. I will have a look.
powerusers.microsoft.com/t5/Microsoft-Power-Automate/ct-p/MPACommunity
Thanks
Hi
I found a work around for the error you are getting
Follow the below steps
Change the version from 5.1 to 5.0
/_apis/wit/attachments?filename=@{items('Apply_to_each')?['name']}&api-version=5.1
Then under the body use expression
binary('here map the email attachment content bytes')
Set the Body is Base64 to Yes
This should work. I have tested this.
@@abm4975 does this work for Excel format also as iam not able to do so
Hi thanks for the video. I have a question: When a new mail received, we can create new devops. But when someone replies the same mail, power automate create a copy of this mail as a new story. How can i stop this? I don't want to create new devops items for followup mails.
Hey, did you ever get an answer for this?
Hello abm, Im having an issue where my project does not show up under Project Name in the connector. I am added as an admin to the project within ADO. Any suggestions please
Hi
Thanks so much for the support.
I was away for few weeks. Do you still need help in this please?
Thanks
The walkthrough is amazing. I am getting the attachments as corrupted files after uploading. I see others with the same issue were you able to solve the problem?
Hi
Thanks so much for the support.
I was away for few weeks. Do you still need help in this please?
Thanks
@@abm4975 no I'm using a work around with SharePoint
Hi
I found a work around for the error you are getting
Follow the below steps
Change the version from 5.1 to 5.0
/_apis/wit/attachments?filename=@{items('Apply_to_each')?['name']}&api-version=5.1
Then under the body use expression
binary('here map the email attachment content bytes')
Set the Body is Base64 to Yes
This should work. I have tested this.
Great video.Can this be achieved when a Microsoft form with an attachment is submitted?
Hi
Yes it is possible. I have another video about From attachments but not specific to DEVOPS. Have a look and if you need further help please let me know.
Thanks
This is awesome. Appreciate the clear walkthrough. Strangely, however, I can't get around the base64 error. I've duplicated your steps and everything works as you saw with the attachment that won't actually open. When I change to base64 = yes, though, i just get the error. If you figure out what is actually happening I'd love to know. :)
Hi @Ciams
Not sure why you couldn't get around that error. For me it's working fine.
Thanks
Hi Ciam, I have had the same problem. My investigation shows the following: I had an Object instead of the raw file to upload. The Content in the previos step was like:
{
"$content-type": "application/pdf",application/octet-stream
"$content": "JVBERi0xLjQKJeLjz9M...... ......hgghg"
}
In that case you need to put the object to a compose step, then create a second compose with the following code: outputs('Compose')['$content']
Now you can upload the output of Compose2 as base64 encoded file to DevOps
Hope that helps
Hi @ciam, I basically followed what @abm as shown in the video here, I came across the same issue, so here is what I did to get the attachments to work items I basically added the get attachments action in apply to each action and them compose action with the expression, here is the expression (base64(base64ToBinary body('Get_Attachment_(V2)')? 'contentBytes']))
and then I passed that output as a body in http post request. That’s it
It then basically creating attachments, multiple attachments from an email also if there is any image in the email body then it also attaches it as attachments and if the email body have any links then it will create hyperlinks which is click
What worked for me (I used Sharepoint Get Attachments > Get attachment contents) is to use the expression base64('Insert attachment contents here') in the Body of the first HTTP action.
Hi @Ciams
I found the issue regarding the attachments. Do the following please
Change the version from 5.1 to 5.0
/_apis/wit/attachments?filename=@{items('Apply_to_each')?['name']}&api-version=5.1
Then under the body use expression
binary('here map the email attachment content bytes')
Set the Body is Base64 to Yes
This should work. I have tested this.
Let me know how it goes.
Thanks
Hi, thanks a lot i really like the video!
Unfortunately i have the issue with base64.
Status now:
in "POST-Request" base64=no
in "PATCH-Request" base64=no
Result:
Attachements are on my work-item.
Problem:
Attachements are empty or cant be open locally.
Can you please explain this:
"Then under the body use expression
binary('here map the email attachment content bytes')
Set the Body is Base64 to Yes"
Hi
Happy to look via a screenshare. Check my Channel about section and connect me via teams.
Thanks
Its solved men thanks :)
Good Day
I like your Idea
Currently I'm searching for a solution:
- The Pictures inside the E-mail are not taken over, they are broken
- --> So I was thinking, is it possible to "add" the E-mail which is created to an Work Item also to add itself as an attachment?
Hi
Please have a look at this
powerusers.microsoft.com/t5/General-Power-Automate/Save-email-to-Sharepoint-document-library-full-email/td-p/4440
Thanks
When people reply to the email.. how can we update the same work item instead of creating a new item whenever someone replies to the same email.
Hi @himanath
Good question. Its going to be a tricky one. You need the work item id for the update. In my opinion its not possible to update from replies of the same emaik.
Thanks
May also need to use the conversation ID from the email. So, if a reply is made on that conversation (thread) then add it to the same work ID.
Create a log with conversation ID to work ID; maybe in Excel or filter array. When an email comes in, check the conversation/work ID log. Then when another email comes in, check to see if the conversaion ID exists in your log. If yes, add new email to the coresponding work ID, else create an new work ID.
Let me know if you figure this out
Is it technically possible to automate a task in power automation whenever a person is mentioned in the azure devops boards in description field ,That mentioned person should get a message in microsoft teams indicating someone is trying to contact him azure devops boards.
The challenge is how you going to extract that persons name from description field unless all of your description might have same pattern. Its a tough one.
@@abm4975 can we do it by script saying that whenever something starts with '@'
I really appreciate your content; it is very good! By any chance, do you have a video to show how to duplicate User Stories or Tasks from one organization to another? I need to create a flow to duplicate everything. This means that from the moment a User Story or Task is created, all the updates made in the original, such as assignments, comments, descriptions, and attachments, need to be duplicated into my other organization. If you can help me with this, I would truly appreciate it! Thank you!
I haven't got a chance to look into this yet.
Hi thank for this amazing video, uri and headers are the same for windows microsoft forms?
Hi
Not sure what you meant by that?
Thanks
@@abm4975 I have tried to replicate your video in a similar flow, the difference is that the trigger is from Microsoft Forms, and just get broken files arrive in my azure board, in the same way I do not get the apply to each automatically when the attachment field is set. microsft forms :(, u can make a video for microsoft forms :D?
Good suggestion. Let me see. Thanks
@@abm4975 I would really appreciate it
@Grimuka_Gamer, So what are the things you collect from MS Forms? Please explain a bit more about your requirement. Are you collecting image as well?
Thanks for the video. Is there a way to get the file from Onedrive or from my personal computer? Could you please create a tutorial on that?
There is already a connector or OneDrive (Personal and Business). Please have a look and let me know if you need any further help in this. For local machine yes can but you need to install Power Automate Gateway configuration.
learn.microsoft.com/en-us/power-automate/gateway-reference
@@abm4975 thank you for your response. I've edited my comment to better express my question. Regarding OneDrive (Personal and Business), I'm struggling to build the flow correctly, and I'm unsure what I might be doing wrong.
@@abm4975 Thank you for your response. I've edited my comment to express myself more clearly. I'm having trouble completing my workflow using OneDrive Business, and I'm sure I'm missing something. Hence, the tutorial request.
Hi
Please check my channel about section and contact me via email address. I could do a screenshare help and see the issue.
Thanks
Hi, in my case it does not work, if the base 64 field is set on YES the flow gives me the following errors:
'Send_an_HTTP_request_to_Azure_DevOps' failed
Unable to parse Base64 encoded bytes. clientRequestId:............
The strange thing is that if I repeat the test with one of the automatic tests and I select a failed test, the flow works fine, this is very strange...
Could someone tell me how to solve the problem? Thank you very much .
Hi,
I haven't come across that error. If you have resolved the issue please let me know as well.
Thanks
I'm having the same issue, did you even find a fix?
Hi
I found a work around for the error you are getting
Follow the below steps
Change the version from 5.1 to 5.0
/_apis/wit/attachments?filename=@{items('Apply_to_each')?['name']}&api-version=5.1
Then under the body use expression
binary('here map the email attachment content bytes')
Set the Body is Base64 to Yes
This should work. I have tested this.
I tried this for ms forms responses but it doesn't work
There is a fix I applied. See my description in my video.
not able to do the same with EXCEL file anything around that
I haven't tried that. It should work.
I am finding that the attachments I add aren't uploading correctly. The size is always 0KB, but there are no errors in my flow. Is this an issue you ran into as well?
Edit: This issue appears to be a bug with PowerAutomate itself. When you send the first email, it will always fail. Once you resubmit the test through PowerAutomate's testing functionality, it will work, despite the fact the requests are identical.
Hi Paul
I need to see the Power Automate. Could you connect me via teams for a screenshare. See my contact details from the channel.
Thanks
@@abm4975 I sent you an email with some redacted details of the flow
@@paulburkart6111 Thanks Paul. I have replied. Please check it.
Hi paul,abm
I am facing the same issue.Were you able to resolve it?
Hi
Make sure your Outlook connector attribute include attachments should set to Yes
Thanks
This is a very helpful video, But i have a small issue my test is working but when i receive mail with attachments it is not visible in the attachments tab I would really appreciate it if you can look into this.
Hi
Could you contact me via teams. Have a look on my channel about section for connecting via email.
Thanks
@@abm4975 I have sent you an email regarding this.
can you suggest a possible time
HI Ajith, Thank you so much for spending time on resolving my issue.
your support is so much appreciated. Cheers!!!
Hi
I found a work around for the error you are getting
Follow the below steps
Change the version from 5.1 to 5.0
/_apis/wit/attachments?filename=@{items('Apply_to_each')?['name']}&api-version=5.1
Then under the body use expression
binary('here map the email attachment content bytes')
Set the Body is Base64 to Yes
This should work. I have tested this.
Thanks for your support.
This is a very helpful video. I can attach the attachments to the work item but cannot open the file attachments. It gives me an error the file type is not supported. @abm4975 @abm I would really appreciate it if you can look into this.
Hi
Thanks so much for the support.
I was away for few weeks. Do you still need help in this please?
Thanks
Hi
I found a work around for the error you are getting
Follow the below steps
Change the version from 5.1 to 5.0
/_apis/wit/attachments?filename=@{items('Apply_to_each')?['name']}&api-version=5.1
Then under the body use expression
binary('here map the email attachment content bytes')
Set the Body is Base64 to Yes
This should work. I have tested this.