處理要求錯誤

Maps Datasets API 會在回應中傳回錯誤訊息。例如,如果您在要求中省略 OAuth 憑證,或是憑證已過期,要求會傳回以下內容:

{
  "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"
        }
      }
    ]
  }
}

如果您在建立資料集時省略必要的主體參數 (例如 displayName),要求會傳回以下內容:

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

如果傳遞無效的資料集 ID,要求會傳回以下內容:

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

如要進一步瞭解錯誤和錯誤處理機制,請參閱「錯誤」一文。