问题
I am getting an HTTP 503 status MSFT Graph API error when attempting to get a Sharepoint site that was successfully created by a Post with the Graph API.
I am using a Developer O365 subscription.
A Python application using the MSFT MSAL library for managing the authentication token is being used. I am able to successfully call other parts of the Graph API with the python app. When using the Graph Explorer logged into my account and with Site permissions I get a correct successful response. The python application worked for an hour or two after about 10-40 requests, but now is frozen in error with serviceNotAvailable.
The AD Application Permissions for the python client are:
- Directory.ReadWrite.All
- Group.Create
- Group.ReadWrite.All
- Sites.FullControl.All
- Sites.Manage.All
- Sites.Read.All
- Sites.ReadWrite.All
- User.Read
The endpoint I am calling GET with is: https://graph.microsoft.com/v1.0/sites/mydomain,some-uuid
The response headers I get are:
{
'Cache-Control': 'private',
'Content-Type': 'application/json',
'request-id': 'ff8256de-f833-4916-85c2-2ee229a68135',
'client-request-id': 'ff8256de-f833-4916-85c2-2ee229a68135',
'x-ms-ags-diagnostic': '{
"ServerInfo":{
"DataCenter":"North Central US",
"Slice":"SliceC",
"Ring":"3",
"ScaleUnit":"002",
"RoleInstance":"AGSFE_IN_3"}}',
'Strict-Transport-Security': 'max-age=31536000',
'Date': 'Wed, 04 Mar 2020 17:47:03 GMT',
'Content-Length': '306'
}
The response body is:
{
"error": {
"code": "serviceNotAvailable",
"message": "The service is not available. Try the request again after a delay. There may be a Retry-After header.",
"innerError": {
"request-id": "ff8256de-f833-4916-85c2-2ee229a68135",
"date": "2020-03-04T17:47:03"
}
}
}
I read in the MSFT docs that this is a throttling error for violating terms of use and that Graph Explorer is not subjected to throttling restrictions. I never get the "Retry-After" header.
Does anyone know how to get my API call to be successful? How to reset the throttling by MSFT? I might make 100 - 150 Graph API calls in an hour.
回答1:
We have been having this issue with multiple Office365 tenants. We reached out to Microsoft and they said it is a server-side bug from their side that they are fixing. They are deploying a fix for one of our customers now. This is not throttling as the error occurs from the first API call. Unfortunately, you can't do anything about it except opening a ticket to Microsoft. By the way, this call had been working fine for over a year. The error started occurring by the end of February 2020.
回答2:
My problem accessing any resource in the sites API was caused by having both the Groups.Create and Groups.ReadWrite.All permissions granted at the same time for application type access.
Removing Groups.Create allowed the all CRUD calls to be successful without serviceNotAvailable errors, even command line calls that just access sites.
Be sure to update admin grant and your token if you change the permissions for a test.
User @user13034886 mentioned the permission clash in another post.
来源:https://stackoverflow.com/questions/60532096/microsoft-graph-api-servicenotavailable-error-when-getting-site-by-id