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

构建Flow迁移Teams列表日历至Outlook时遇日期格式转换错误

解决Power Automate Flow迁移Teams日历事项到Outlook的保存错误

问题描述

我要构建一个Power Automate Flow,将Teams列表中的日历事项迁移至Outlook,但保存Flow时失败。

我的Flow操作代码如下:

{
  "type": "OpenApiConnection",
  "inputs": {
    "parameters": {
      "table": "...=",
      "item/subject": "@triggerBody()?['Title_x0020_Category']",
      "item/start": "@triggerBody()?['Beginday']",
      "item/end": "@triggerBody()?['Endday']",
      "item/timeZone": "(UTC+01:00) Amsterdam, Berlin, Bern, Rome, Stockholm, Vienna"
    },
    "host": {
      "apiId": "/providers/Microsoft.PowerApps/apis/shared_office365",
      "connection": "shared_office365",
      "operationId": "V4CalendarPostItem"
    }
  },
  "runAfter": {},
  "runtimeConfiguration": {
    "staticResult": {
      "staticResultOptions": "Enabled",
      "name": "Create_event_(V4)0"
    }
  }
}

收到的错误信息:

Flow保存失败,错误码为'OpenApiOperationParameterValidationFailed',错误消息为'工作流操作"Create_event_(V4)"中的输入参数"item"验证失败:路径"item/start"中值为"@triggerBody()?['Beginday']"、类型/格式为"String/date-time"的参数无法转换为类型/格式"String/date-no-tz"'。

问题原因

Outlook的「创建事件(V4)」操作中,当指定item/timeZone参数时,item/start和item/end需要传入不带时区信息的日期时间格式(即date-no-tz),但Teams列表返回的Beginday和Endday是带时区的date-time格式,导致格式不匹配触发验证失败。

解决方案

使用Power Automate的formatDateTime函数,将带时区的日期时间转换成不带时区的ISO格式字符串,替换原item/start和item/end的值:

修改后的参数部分代码:

"item/subject": "@triggerBody()?['Title_x0020_Category']",
"item/start": "@formatDateTime(triggerBody()?['Beginday'], 'yyyy-MM-ddTHH:mm:ss')",
"item/end": "@formatDateTime(triggerBody()?['Endday'], 'yyyy-MM-ddTHH:mm:ss')",
"item/timeZone": "(UTC+01:00) Amsterdam, Berlin, Bern, Rome, Stockholm, Vienna"

说明

  • formatDateTime函数会提取原日期时间的数值部分,生成不带时区的yyyy-MM-ddTHH:mm:ss格式字符串,符合date-no-tz的格式要求。
  • 已指定item/timeZone,Outlook会自动使用该时区解析start和end的时间,无需在时间字符串中携带时区信息。

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.06.17 09:10:04