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

Power Automate中SharePoint文件重命名HTTP请求步骤报错咨询

Power Automate SharePoint HTTP请求重命名文件报错解决

问题描述

在Power Automate的「向SharePoint发送HTTP请求」步骤中,尝试给文件重命名并追加Compose步骤结果时触发错误:

The expression "web/GetFileByServerRelativeUrl('/sites/ESMManila/Shared Documents/General/WorkloadPlanning/CurrentWorkPlan.xlsx')/moveto(newurl=concat('/sites/ESMManila/Shared Documents/General/WorkloadPlanning/',outputs('Compose'),'WorkPlan','.xlsx'))" is not valid.

使用的URI为:
_api/web/GetFileByServerRelativeUrl('/sites/ESMManila/Shared%20Documents/General/WorkloadPlanning/CurrentWorkPlan.xlsx')/moveto(newurl=concat('/sites/ESMManila/Shared%20Documents/General/WorkloadPlanning/',outputs('Compose'),'WorkPlan','.xlsx'))

错误原因

你把Power Automate的concat()表达式直接嵌入到了SharePoint REST API的URI中,SharePoint REST API无法识别Power Automate的表达式语法,moveto方法的newurl参数需要传入已经拼接完成的完整字符串路径,而非表达式本身。

解决步骤

  • 第一步:先拼接好完整的新文件路径
    新增一个Compose步骤(或复用现有步骤扩展),在表达式框中写入拼接规则:

    concat('/sites/ESMManila/Shared Documents/General/WorkloadPlanning/', outputs('Compose'), 'WorkPlan', '.xlsx')
    

    若原Compose输出包含多余空格,可添加trim()处理:concat(..., trim(outputs('Compose')), ...)

  • 第二步:修改HTTP请求的URI
    将URI中的concat(...)替换为新Compose步骤的动态输出,确保传入的是解析后的完整路径:

    _api/web/GetFileByServerRelativeUrl('/sites/ESMManila/Shared%20Documents/General/WorkloadPlanning/CurrentWorkPlan.xlsx')/moveto(newurl='@{outputs('新Compose步骤名称')}')
    

    如果需要覆盖同名文件,可添加flags=1参数(1表示强制覆盖,0为不覆盖):

    _api/web/GetFileByServerRelativeUrl('/sites/ESMManila/Shared%20Documents/General/WorkloadPlanning/CurrentWorkPlan.xlsx')/moveto(newurl='@{outputs('新Compose步骤名称')}', flags=1)
    
  • 第三步:确认请求配置
    确保HTTP请求的方法为POST,请求头添加Accept: application/json;odata=verbose,避免返回格式异常。

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.07.31 10:20:22