如何通过File Identifier获取Microsoft Forms上传的单个文件内容?
Microsoft Forms上传文件后Power Automate获取内容相关问题
期望行为
- 通过Microsoft Forms上传文件
- 获取文件内容
- 在新位置创建新文件
- 删除原始文件
实际行为
我在第2步遇到报错,错误信息如下:
"body": { "status": 404, "message": "File not found\r\nclientRequestId: yadda-yadda\r\nserviceRequestId: yadda-yadda" }
已尝试操作
Power Automate流的触发器为:When a new response is submitted
后续动作为:Get response details
该动作的Raw Outputs大致结构如下:
"body": { "responder": "me@domain.com", "submitDate": "7/5/2021 3:17:56 AM", "my-text-field-01": "text string here", "my-file-upload-field-01": [{.....}], "my-file-upload-field-02": [{.....}], "my-text-field-02": "text string here" }
文件上传字段的结构如下:
{ "name": "My File Name_Uploader Name.docx", "link": "https://my-tenant.sharepoint.com/sites/my-team-site/_layouts/15/Doc.aspx?sourcedoc=%7B0F1C3107-32C9-4CEF-B4BA-87E57C9DC514%7D&file=My%20File%20Name_Uploader%20Name.docx&action=default&mobileredirect=true", "id": "01NSAULIQHGEOA7SJS55GLJOUH4V6J3RIU", "type": null, "size": 20400, "referenceId": "01NSAULISZJG7M56NSV5AIDUQFHG3BOBCH", "driveId": "letters-and-numbers-here", "status": 1, "uploadSessionUrl": null }
该对象中的id或referenceId值,与SharePoint文档库中文档属性页显示的Document ID并不对应:
可以通过以下表达式在流中获取上传文件的属性:
json(body('Get_response_details')?['random-letters-and-numbers'])[0]['name'] json(body('Get_response_details')?['random-letters-and-numbers'])[0]['driveId'] json(body('Get_response_details')?['random-letters-and-numbers'])[0]['id']
接下来要执行Get file content动作,可使用的相关操作包括:
SharePoint连接器
Get file contentGet file content using path
OneDrive for Business连接器Get file contentGet file content using path
我想要使用Get file content(比传入硬编码路径更灵活)。多个公开教程建议传给该动作的File ID参数值应为driveId和id的拼接,即:driveId.id
但按此方式尝试后:
仍然返回相同的404报错。
核心疑问
- 应该往
Get file content的File Identifier参数中传入什么值? - 希望明确SharePoint、Power Automate、MS Graph等产品中提到的各类
id的区别,以及为什么部分场景建议使用driveId.id作为参数值。不同场景下无法获取对应文件id的问题很麻烦,例如Delete file动作需要File Identifier来删除Microsoft Forms上传的文件,但无法从Get response details的响应中获取该值。
补充信息
补充1
查阅相关技术博文后,猜测File Identifier实际指的是文件路径,例如:
/Shared Documents/Apps/Microsoft Forms/My Form Name/Question/My File Name.docx
通过UI手动选择文件传入上述路径可以正常运行,但动态传入文件名的写法不生效:
/Shared Documents/Apps/Microsoft Forms/My Form Name/Question/@{variables('file_upload_wor_document_name')}
补充2
后续发现上述动态路径代码片段作为File Identifier传给SharePoint的Get file content using path连接器可以正常运行。
内容的提问来源于stack exchange,提问作者user1063287
相关产品推荐
相关产品推荐

