Strange behavior when using REST APIs? (Office 365 Management APIs)
I'm trying to build a tool which collects audit events from O365.
I'm using this Office365 Management APIs documentation https://learn.microsoft.com/en-us/office/office-365-management-api/office-365-management-activity-api-reference#activity-api-operations and Python requests package.
It works great but sometimes the request made to those audit URLs (for example, https://manage.office.com/api/v1.0/<tenant-id>/activity/feed/subscriptions/content?contentType=DLP.All&startTime=2023-08-07T18:34:10&endTime=2023-08-07T18:36:10) hangs. So I set a timeout of 60 seconds and, if timeout occurs, wait, let's say 15 seconds, and retry the request. Do it for, let's say, 3 times, and abort if none of the attempts is successful.
Now, it seems like working a little better. Sometimes I catch a timeout (sometimes even 503 Server Error: Service Unavailable) but after one or two retries to an URL like https://manage.office.com/api/v1.0/<tenant-id>/activity/feed/subscriptions/content?contentType=DLP.All&startTime=2023-08-07T18:34:10&endTime=2023-08-07T18:36:10 it succeed. Other times, there is no success even after 3 retries, for example on this URL: https://manage.office.com/api/v1.0/<tenant-id>/activity/feed/subscriptions/content?contentType=Audit.AzureActiveDirectory&startTime=2023-08-07T21:24:11&endTime=2023-08-07T21:27:28
Is this expected behavior when working directly with REST APIs? In my past experience when I was working with clouds and using dedicated python libraries I didn't encounter something similar. Perhaps those libraries handle those cases (like I explained above) behind the interface?
Thank you!!