Subscription expiration time error - microsoft-graph-api

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?

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.".

Related

Execution Timeout Expired Azure Logic App

We have an excessively complex stored procedure in SQL Server (which I did not write and cannot change).
I created an Azure logic app, using a "Recurrence" (not a "Sliding Window") trigger, with an "Execute stored procedure (V2)" action, and set the "frequency" to run daily at 22:00 (10pm).
But, I try running it manually just to test it (Run Trigger).
It runs for between 9 1/2 and 10 1/2 minutes, then fails with a "Bad Gateway" and "Error 504" and "Timeout Expired" error (see JSON at bottom):
How do I increase the timeout? Is there a simple setting buried in Azure that I'm missing?
I never specified any gateway, and another, much simpler stored procedure with no gateway specification executed fine.
And lastly, I am an Azure neophyte.
Thank you.
{
"error": {
"code": 504,
"source": "logic-apis-eastus2.azure-apim.net",
"clientRequestId": "{I removed the client request Id before posting this}",
"message": "BadGateway",
"innerError": {
"status": 504,
"message": "Execution Timeout Expired. The timeout period elapsed prior to completion of the operation or the server is not responding.\r\nclientRequestId: {I removed the client request Id before posting this}",
"error": {
"message": "Execution Timeout Expired. The timeout period elapsed prior to completion of the operation or the server is not responding."
},
"source": "sql-eus2.azconn-eus2.p.azurewebsites.net"
}
}

Google Calendar API events list time zone issue

Since mid of last week I witnessed increasing issues with the events list query params for upper and lower bounds. Since the weekend it is no longer working at all.
Issue summary:
Positive timezone offsets no longer accepted in events list query params for time bounds.
Api call:
GET https://www.googleapis.com/calendar/v3/calendars/<myCalendarId>/events
with query params: ?timeMin=2020-12-01T09:31:04+0100
Expected behavior and behavior until around Nov 25th, on some servers until Nov 27th:
{
"kind": "calendar#events",
"etag": "\"blahblah\"",
"summary": "blahblah",
"updated": "2020-12-01T07:46:56.357Z",
"timeZone": "Europe/Berlin",
"accessRole": "owner",
"defaultReminders": [
{
"method": "popup",
"minutes": 30
}
],
"nextSyncToken": "blahblah",
"items": [
...
Actual behavior / response body:
{
"error": {
"errors": [
{
"domain": "global",
"reason": "badRequest",
"message": "Bad Request"
}
],
"code": 400,
"message": "Bad Request"
}
}
Further details:
Apparently the "bad request" response is solely induced by the plus (+) symbol before the time zone offset. Changing the "+" to a "-" in the above request will return a valid response as expected only that the offset is wrong (in this case by two hours as it should be).
Writing the offset with or without ":" (e.g. +01:00 vs +0100) does not affect results.
Most likely I have missed something like a depreciation of positive time zone offsets or I was anyway using a wrong time format since I am admittedly not an expert in the RFC3339.
The other option is that the Google calendar team has updated their parser in their calendar API and in the wake of that deployed a bug. In that case a test case should be added to the pipeline for testing several time zone offsets including the limits.
I would be happy to receive advice on how to gracefully select and time zone east of UTC.
Thanks a lot in advance!
There is no such deprecation, but when you make an HTTP request you need to URL encode the parameters
Sample:
https://www.googleapis.com/calendar/v3/calendars/primary/events?q=timeMin%3D2020-12-01T09%3A31%3A04%2B0100

Microsoft Graph Calendar API OData filter on start / end date-times

I am trying to retrieve only certain events from a user's calendarView in the Microsoft Graph Calendar API.
I've written the following proof-of-concept code:
start = self.date_to_string(datetime.datetime.now())
end = self.date_to_string(datetime.datetime.now() + datetime.timedelta(days = 365 * 3))
start, end = min(start, end), max(start, end)
data = await self.make_request(url, parameters = {
"startDateTime" : start,
"endDateTime" : end,
"$filter" : "Start/DateTime ge '2017-07-01T08:00'" # and (start/dateTime ge '2020-10-21T16:31:40.5470240')"
})
Though, when I make the request, this is what I'm getting
{
"error": {
"code": "ErrorInternalServerError",
"message": "An internal server error occurred. The operation failed.",
"innerError": {
"date": "2020-10-22T15:20:56",
"request-id": "bef9513d-a5b3-4b23-b37a-8f341f6822ae",
"client-request-id": "bef9513d-a5b3-4b23-b37a-8f341f6822ae"
}
}
}
Removing the $filter helps, but I do need it (I would like to filter events starting in a date-time range and/or ending in a date-time range).
I tried several things:
cast(2017-07-01T08:00 as Edm.DateTimeOffset)
2017-07-01T08:00Z
2017-07-01T08:00Z+00:00
Actually pretty much any combination one can think of, but to no avail. Note that official docs use different formats, including '2017-07-01T08:00' (as in ?$filter=start/dateTime ge '2017-07-01T08:00')
Any ideas?

504 Gateway Timeout (UnknownError) when trying to track changes in a user's calendar

For our internal application we synchronize our user's calendars (in our Office 365 tenant) with a local "cache" in our database. We're using the new Delta Queries in Microsoft Graph to do track these changes.
Most of the calendars synchronize correctly, but for some reason there is one single calendar where we consistently hit a 504 Gateway Timeout error when attempting to request the events using the nextLink received from the first request.
First request:
GET https://graph.microsoft.com/v1.0/users/<userId>/calendars/<calendarId>/calendarView/delta?startDateTime=2017-06-10t00%3A00%3A00Z&endDateTime=2018-06-10t00%3A00%3A00Z
First response:
{
"#odata.context": "https://graph.microsoft.com/v1.0/$metadata#Collection(event)",
"#odata.nextLink": "https://graph.microsoft.com/v1.0/users/<userId>/calendars/<calendarId>/calendarView/delta?$skiptoken=R0usmcdvmMuZCBYV0hguCGmIJqcU0n_6jVFWUlNKbXkBKYVlxLSMsISZI5sLLLJyLJF8hZIj0PURpAeP_XxydW_qbMUoFMTXjOpLa8Ta6rxMRA7Wv6IHYfjyLPcDzCbM_hKvTgq8BZaBeJv-a61mebF6X2wT4HqCAGL5lL4nLZabHk1nD9GbWJ0a4Qq0M41_GPYxEi5YNe9u1673SQ1Djw.F85xXB6GjtO7myCQCOgFvzp1G7mQB0BvuHQJyn0CICQ",
"value": [
<list of events>
]
}
Second request:
GET https://graph.microsoft.com/v1.0/users/<userId>/calendars/<calendarId>/calendarView/delta?$skiptoken=R0usmcdvmMuZCBYV0hguCGmIJqcU0n_6jVFWUlNKbXkBKYVlxLSMsISZI5sLLLJyLJF8hZIj0PURpAeP_XxydW_qbMUoFMTXjOpLa8Ta6rxMRA7Wv6IHYfjyLPcDzCbM_hKvTgq8BZaBeJv-a61mebF6X2wT4HqCAGL5lL4nLZabHk1nD9GbWJ0a4Qq0M41_GPYxEi5YNe9u1673SQ1Djw.F85xXB6GjtO7myCQCOgFvzp1G7mQB0BvuHQJyn0CICQ
Second response:
504 Gateway Timeout
{
"error": {
"code": "UnknownError",
"message": "",
"innerError": {
"request-id": "0784cffb-cba7-424b-be1d-74b2bfef5da1",
"date": "2017-07-10T09:11:33"
}
}
}
I've tried executing the script a few times over the last week, but the request consistently fails when using requesting the second page. Other calendars synchronize with no issues, so I don't really know how to debug these kind of issues. Is there anything we can do to resolve this issue?
I'm working with the team that owns Calendar sync to check where the latency in the stack is causing this time out. I'll post as soon as they have root caused this. I may need more info on what is special about this one Calendar encountering this issue.
Thanks,
Sri

Filter files by date range in OneDrive

I would like to obtain the OneDrive content using Microsoft Graph filtered by date so that only files created between particular dates are obtained.
I have tried:
/v1.0/me/drive/items/{id}/children?filter=createdDateTime ge 2016-02-26T14:41:09Z
but get following response
"error": {
"code": "invalidRequest",
"message": "The request is malformed or incorrect.",
"innerError": {
"request-id": "c636022f-2fa9-4e41-b8fc-63be5fc5e681",
"date": "2017-04-07T10:05:46"
}
}
I have also tried:
/v1.0/me/drive/root/children?filter=name eq 'folderapr05'
and it works.
Does OneDrive support filter parameter for dates?
Filtering by dateTime isn't supported.
If you're attempting to do this for the purposes of syncing with OneDrive, you may want to take a look at delta. This method allows your app to track changes to a drive and its children over time.

Resources