订阅到期时间错误

时间:2018-04-20 09:55:03

标签: microsoft-graph subscriptions

我尝试使用特定的到期日期当前日期+ 4320分钟创建订阅:

Date nowDateTime = new Date();
    LocalDateTime ldt = LocalDateTime.ofInstant(nowDateTime.toInstant(), ZoneOffset.UTC);
    LocalDateTime localDateTime = ldt.plusMinutes(4230);
    Date out = Date.from(localDateTime.atZone(ZoneOffset.UTC).toInstant());
    return new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSSSSSS'Z'").format(out);

但我得到错误:

{
  "error": {
    "code": "ExtensionError",
    "message": "Subscription expiration can only be 4230 minutes in the future.",
    "innerError": {
      "request-id": "a0744d2b-5739-4904-9cac-33762e058d32",
      "date": "2018-04-20T09:02:41"
    }
  }
}

我设置过期时间错误吗?

1 个答案:

答案 0 :(得分:0)

我已经尝试过您共享的客户端代码。逻辑生成的日期和值的格式看起来很符合API的预期,并且对我有用。

我认为没有任何理由在到期时间上使用绝对时间上限。从您调用服务处理请求的时间开始,会有一些网络延迟。我建议使用小于4230的值。

您是否可以尝试设置 localDateTime = ldt.plusMinutes(4200),因为错误显示消息“订阅过期只能在将来4230分钟。”。

相关问题