You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Power Automate邮箱触发流上传Azure DevOps附件遇Base64解码失败求助

Power Automate邮件触发时上传Azure DevOps附件失败,重试却正常的问题

我正在开发一个Power Automate流,触发条件为共享邮箱收到新邮件,功能是在Azure DevOps对应项目和迭代路径中创建工作项,并将邮件中的所有附件、图片保存到该工作项中。

目前使用「Send an HTTP request to Azure DevOps」连接器存储附件,操作完全遵循官方文档步骤:

  • 将文件内容转换为Base64字符串,填入「Body」参数;
  • 将「Body is Base64」参数设为Yes。

遇到的异常情况

  • 新邮件触发工作流时,会抛出Base64解码失败错误:

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

  • 但在Power Automate中重新测试同一个失败的运行实例,流程就能正常执行,文件可成功上传至Azure DevOps;
  • 若将「Body is Base64」设为No,工作流看似执行成功,但Azure DevOps中的附件打开后损坏、格式异常。

我的工作流配置细节

1. 上传附件的HTTP请求设置

  • 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

2. Parse JSON块设置

  • Content:body('Send_an_HTTP_request_to_Azure_DevOps')
  • Schema:
{
"type": "object",
"properties": {
"id": {
"type": "string"
},
"url": {
"type": "string"
}
}
}

3. 关联附件到工作项的PATCH请求设置

  • 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

补充:右侧分支仅用于测试其他获取附件的方式,已确认数据为Base64编码,后续会移除。

相关截图

  1. 工作流配置截图1
  2. 工作流配置截图2
  3. 工作流配置截图3

有没有人遇到过这个问题?


内容的提问来源于stack exchange,提问作者Sebastian Gregori

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.06.13 16:20:09