admin 管理员组

文章数量: 1086019

I'm working on a flow that gets triggered when a new email arrives to a shared mailbox. It creates a new work item in Azure DevOps in the right project and iteration path. The goal is to save all attachments and images coming from emails into the work item created. Currently I'm using the connector "Send an HTTP request to Azure DevOps" to store the attachments into the work items since it seems to be the only way and I'm following the docs steps ():

1- Convert file content to a Base64 string and put it in "Body" parameter.

2- Set "Body is Base64" parameter to Yes.

The file content is being set in the body parameter and it is base64 encoded. However when a new email arrives and the workflow gets triggered it fails decoding the base64. The error is the following:

"Action 'Send_an_HTTP_request_to_Azure_DevOps' failed: Unable to parse Base64 encoded bytes."

The weird thing is that if I re-test the same exact run that failed from Power Automate it then process everything properly and the files gets to Azure DevOps properly. If I change "Body is Base64" to No, then the workflow seems to be successful but when I try to open any attachment in Azure DevOps it's corrupted, the format is not OK.

Did anyone experience this issue?

This is how I configured the workflow. In the first "Send an HTTP request to Azure DevOps" I've set:

Method: POST

Relative URI: /_apis/wit/attachments?filename=@{item()?['name']}&api-version=5.0

Headers Content-Type = application/octet-stream

Body: contentBytes

Body is base64? Yes

In the Parse JSON block, I've set the following:

Content: body('Send_an_HTTP_request_to_Azure_DevOps')

Schema:

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

Then I've configured a PATCH http request to Azure DevOps:

Method: PATCH

Relative URI: /_apis/wit/workitems/@{outputs('Create_a_work_item')?['body/id']}/?api-version=5.0

Headers

Content-Type = application/json-patch+json

Body: [ { 'op': 'add', 'path': '/relations/-', 'value': { 'rel': 'AttachedFile', 'url': '@{body('Parse_JSON')?['url']}', 'attributes': { 'comment': 'Bug details', 'name':'@{items('Apply_to_each')?['name']}' } } } ]

Body is base64? No

That's all. The right branch was added to test other ways to get the attachments properly and to confirm the data is being base64 encoded.

SCREENSHOT HERE --> 1

WORKFLOW HERE -->(The right branch was made for testing purposes and won't be part of the workflow in future) 2

INPUT PARAMETER SHOWING BASE64 CODE --> 3

Thanks,

Sebastian

本文标签: power automateSave attachments to Azure DevOps when new email arrives to shared mailboxStack Overflow