代码之家  ›  专栏  ›  技术社区  ›  baywet

带有到期日期标记的SendMail返回错误InvalidArgumenterror

  •  0
  • baywet  · 技术社区  · 6 年前

    图形资源管理器中的以下请求可以工作。
    https://graph.microsoft.com/v1.0/me/sendMail

    {
      "message": {
        "subject": "Meet for lunch?",
        "body": {
          "contentType": "Text",
          "content": "The new cafeteria is open."
        },
        "toRecipients": [
          {
            "emailAddress": {
              "address": "vincent@baywet.onmicrosoft.com"
            }
          }
        ],
        "flag": {
          "flagStatus": "flagged"
        }
      },
      "saveToSentItems": "false"
    }
    

    具有以下有效负载的同一请求失败

    {
      "message": {
        "subject": "Meet for lunch?",
        "body": {
          "contentType": "Text",
          "content": "The new cafeteria is open."
        },
        "toRecipients": [
          {
            "emailAddress": {
              "address": "vincent@baywet.onmicrosoft.com"
            }
          }
        ],
        "flag": {
          "flagStatus": "flagged",
          "dueDateTime": {
            "timeZone": "Pacific Standard Time",
            "dateTime": "2019-01-25T19:58:27"
          }
        }
      },
      "saveToSentItems": "false"
    }
    

    出现以下错误消息

    {
        "error": {
            "code": "ErrorInvalidArgument",
            "message": "The request is invalid.",
            "innerError": {
                "request-id": "5e335c05-071b-4b23-8511-006db9e6e883",
                "date": "2019-01-24T20:03:45"
            }
        }
    }
    

    请注意,唯一的区别是以下节点(到期日)

    "dueDateTime": {
            "timeZone": "Pacific Standard Time",
            "dateTime": "2019-01-25T19:58:27"
          }
    

    根据 documentation ,我应该通过一个 DateTimeTimeZone 对象,即使这篇特定的文章没有示例,根据 similar examples .
    documentation 以及 known issues 所以 我想知道这个有效负载有什么问题,如何在发送电子邮件时设置带有截止日期的标志

    0 回复  |  直到 6 年前
        1
  •  0
  •   Jeremy Thake MSFT    5 年前

    很抱歉回信迟了。9个月后,我终于有空和一个工程师谈了谈。看看后端逻辑。必须同时设置开始日期和到期日期才能使其生效。

    所以你必须这么做

      "flag": {
          "flagStatus": "flagged",
          "dueDateTime": {
            "timeZone": "Pacific Standard Time",
            "dateTime": "2019-12-25T19:58:27"
          },
          "startDateTime": {
            "timeZone": "Pacific Standard Time",
            "dateTime": "2019-11-25T19:58:27"
          }
    

    我要把文件更新一下。

    推荐文章