處理要求錯誤

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

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