Search code examples
microsoft-graph-apisubscriptions

Subscription expiration time error


I try to create a subscription with a specific expiration date current date + 4320 minutes like this:

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);

But I get error:

{
  "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"
    }
  }
}

Am I setting expiration time wrong?


Solution

  • I have experimented with the client code shared by you. The format of the date and value generated by your logic looks good for the expectation of the API and it worked for me.

    I do not see any reason for using the absolute limit of time upper bound on the expiration time. There would be some network latencies from the period you make call to the time where the request is processed by the service. I recommend using the value smaller than 4230.

    Could you try setting the localDateTime = ldt.plusMinutes(4200) since the error is giving message "Subscription expiration can only be 4230 minutes in the future.".