Struttura degli errori dell'API Google Classroom
Mantieni tutto organizzato con le raccolte
Salva e classifica i contenuti in base alle tue preferenze.
L'API Classroom restituisce informazioni sugli errori che possono aiutare gli sviluppatori
a eseguire il debug dei problemi e a fornire informazioni utili e fruibili agli utenti finali. Questa guida spiega come analizzare le informazioni sugli errori restituite dall'API.
L'API Classroom restituisce due livelli di informazioni sugli errori:
- Codice di errore HTTP nell'intestazione.
- Un oggetto nel corpo della risposta con dettagli aggiuntivi.
Struttura del messaggio di errore
Gli errori restituiti nel corpo della risposta includono i seguenti campi:
code
: il codice di errore HTTP numerico. Ad esempio, 403
.
message
: Altri dettagli sull'errore. Se disponibile, il messaggio di errore
è preceduto da @
e da un tipo di errore specifico. Ad esempio
@ClassroomApiDisabled
.
status
: lo stato della richiesta HTTP. Ad esempio, PERMISSION_DENIED
o
NOT_FOUND
.
Se una richiesta non è andata a buon fine con un errore ClassroomApiDisabled
, la risposta sarà:
{
"error": {
"code": 403,
"message": "@ClassroomApiDisabled The user is not permitted to access the Classroom API.",
"status": "PERMISSION_DENIED"
}
}
Puoi utilizzare il corpo della risposta per eseguire il debug della causa dell'errore e
fornire informazioni utili agli utenti. Includi uno spazio finale quando controlli
un messaggio di errore specifico per evitare di trovare corrispondenze con altri valori che iniziano con
la stessa stringa. Nell'esempio di errore fornito, puoi verificare se il campo del messaggio inizia con "@ClassroomApiDisabled "
per presentare informazioni appropriate agli utenti.
Consulta la pagina Errori comuni per informazioni su alcuni errori che
possono essere restituiti dall'API Classroom.
Salvo quando diversamente specificato, i contenuti di questa pagina sono concessi in base alla licenza Creative Commons Attribution 4.0, mentre gli esempi di codice sono concessi in base alla licenza Apache 2.0. Per ulteriori dettagli, consulta le norme del sito di Google Developers. Java è un marchio registrato di Oracle e/o delle sue consociate.
Ultimo aggiornamento 2025-08-29 UTC.
[null,null,["Ultimo aggiornamento 2025-08-29 UTC."],[],[],null,["# Google Classroom API error structure\n\nThe Classroom API returns error information that can help developers\ndebug issues and provide helpful, actionable information to end users. This\nguide explains how to parse error information returned from the API.\n\nThe Classroom API returns two levels of error information:\n\n- HTTP error code in the header.\n- An object in the response body with additional details.\n\nError message structure\n-----------------------\n\nErrors returned in the response body include the following fields:\n\n- `code`: The numerical HTTP error code. For example, `403`.\n- `message`: Additional details about the error. When available, the error message is prepended with `@` and a specific error type. For example, `@ClassroomApiDisabled`.\n- `status`: The HTTP request status. For example, `PERMISSION_DENIED` or `NOT_FOUND`.\n\nIf a request failed with a [`ClassroomApiDisabled`](/workspace/classroom/troubleshooting/common-errors#classroom-api-disabled) error, the response would\nbe: \n\n {\n \"error\": {\n \"code\": 403,\n \"message\": \"@ClassroomApiDisabled The user is not permitted to access the Classroom API.\",\n \"status\": \"PERMISSION_DENIED\"\n }\n }\n\nYou can use the response body to help you debug the cause of the error and\nprovide helpful information to users. Include a trailing space when checking\nfor a specific error message to avoid matching other values that start with\nthe same string. In the provided error example, you can check if the message\nfield begins with `\"@ClassroomApiDisabled \"` to present appropriate information\nto users.\n\nReference the [Common errors](/workspace/classroom/troubleshooting/common-errors) page for information on some errors that\ncan be returned by the Classroom API."]]