Gestire gli errori della richiesta

L'API Maps Datasets restituisce messaggi di errore come parte della risposta. Ad esempio, se ometti il token OAuth dalla richiesta o se il token è scaduto, la richiesta restituisce:

{
  "error": {
    "code": 401,
    "message": "Request is missing required authentication credential.
    Expected OAuth 2 access token, login cookie or other valid authentication credential.
    See https://developers.google.com/identity/sign-in/web/devconsole-project.",
    "status": "UNAUTHENTICATED",
    "details": [
      {
        "@type": "type.googleapis.com/google.rpc.ErrorInfo",
        "reason": "CREDENTIALS_MISSING",
        "domain": "googleapis.com",
        "metadata": {
          "method": "google.maps.mapsplatformdatasets.v1alpha.MapsPlatformDatasetsV1Alpha.ListDatasets",
          "service": "mapsplatformdatasets.googleapis.com"
        }
      }
    ]
  }
}

Se ometti un parametro del corpo obbligatorio, come displayName durante la creazione di un set di dati, la richiesta restituisce:

{
  "error": {
    "code": 400,
    "message": "display_name: Display name must be provided",
    "status": "INVALID_ARGUMENT"
  }
}

Se passi un ID set di dati non valido, la richiesta restituisce:

{
  "error": {
    "code": 404,
    "message": "Dataset not found",
    "status": "NOT_FOUND"
  }
}

Per maggiori informazioni su errori e gestione degli errori, consulta Errori.