本页面介绍了如何使用 API Explorer 尝试 Dataproc Metastore API 方法。API Explorer 是附加到方法的 REST API 参考页面的微件。它会显示为一个面板,标题为试用此 API。
API Explorer 是在 Dataproc Metastore API 中试用方法的绝佳方法,无需编写任何代码。该微件会显示一个表单,其中显示每种方法的参数。填写表单,点击执行,然后查看结果。
您还可以通过点击面板顶部的关闭按钮来隐藏微件,或通过点击全屏按钮将其展开到全屏。
准备工作
Sign in to your Google Cloud account. If you're new to
Google Cloud,
create an account to evaluate how our products perform in
real-world scenarios. New customers also get $300 in free credits to
run, test, and deploy workloads.
In the Google Cloud console, on the project selector page,
select or create a Google Cloud project.
[[["易于理解","easyToUnderstand","thumb-up"],["解决了我的问题","solvedMyProblem","thumb-up"],["其他","otherUp","thumb-up"]],[["很难理解","hardToUnderstand","thumb-down"],["信息或示例代码不正确","incorrectInformationOrSampleCode","thumb-down"],["没有我需要的信息/示例","missingTheInformationSamplesINeed","thumb-down"],["翻译问题","translationIssue","thumb-down"],["其他","otherDown","thumb-down"]],["最后更新时间 (UTC):2025-08-27。"],[[["\u003cp\u003eAPI Explorer allows you to test Dataproc Metastore API methods directly from the REST API reference page without coding, using a form-based interface.\u003c/p\u003e\n"],["\u003cp\u003eYou can execute a minimal request by filling in only the required parameters, which are indicated by a red bar, and view the results directly below the Execute button.\u003c/p\u003e\n"],["\u003cp\u003eOptional parameters, including a unique request ID or using fields to filter output, can be used to customize the request beyond the basic required inputs.\u003c/p\u003e\n"],["\u003cp\u003eBe mindful of common formatting issues, such as avoiding quotation marks around values, properly quoting strings within filters, and not using backslashes or URL encoding in the form fields.\u003c/p\u003e\n"],["\u003cp\u003eThe API Explorer uses Google OAuth 2.0 by default for authentication, and you can bookmark URLs to save and reuse populated forms for debugging and re-execution.\u003c/p\u003e\n"]]],[],null,["# Use the API Explorer\n\nThis page explains how to use the API Explorer to try out\nDataproc Metastore API methods. API Explorer is a widget attached to\nthe REST API reference page for a method. It appears as a panel with the title\n**Try this API**.\n\nThe API Explorer is an excellent way to try out methods in the\nDataproc Metastore API without having to write any code. The\nwidget presents a form showing the parameters for each method. Fill in the form,\nclick **Execute**, and see the results.\n\nYou can also hide the widget by clicking the close button at the top of the\npanel, or expand it to full screen by clicking the full screen button.\n\nBefore you begin\n----------------\n\n- Sign in to your Google Cloud account. If you're new to Google Cloud, [create an account](https://console.cloud.google.com/freetrial) to evaluate how our products perform in real-world scenarios. New customers also get $300 in free credits to run, test, and deploy workloads.\n- In the Google Cloud console, on the project selector page,\n select or create a Google Cloud project.\n\n | **Note**: If you don't plan to keep the resources that you create in this procedure, create a project instead of selecting an existing project. After you finish these steps, you can delete the project, removing all resources associated with the project.\n\n [Go to project selector](https://console.cloud.google.com/projectselector2/home/dashboard)\n-\n\n\n Enable the Dataproc Metastore API.\n\n\n [Enable the API](https://console.cloud.google.com/flows/enableapi?apiid=metastore.googleapis.com)\n\n- In the Google Cloud console, on the project selector page,\n select or create a Google Cloud project.\n\n | **Note**: If you don't plan to keep the resources that you create in this procedure, create a project instead of selecting an existing project. After you finish these steps, you can delete the project, removing all resources associated with the project.\n\n [Go to project selector](https://console.cloud.google.com/projectselector2/home/dashboard)\n-\n\n\n Enable the Dataproc Metastore API.\n\n\n [Enable the API](https://console.cloud.google.com/flows/enableapi?apiid=metastore.googleapis.com)\n\n\u003cbr /\u003e\n\nAccess the API Explorer\n-----------------------\n\nThe API Explorer is attached to the reference page for each REST API method. To\nfind the widget, go to the reference page for a method, for example, the\n[reference page for Dataproc Metastore `projects.locations.services.create`](/dataproc-metastore/docs/reference/rest/v1/projects.locations.services/create).\n\nExecute a minimal request\n-------------------------\n\nMost methods have some required parameters and some optional ones. The required\nones are marked with a red bar until they are filled. You can execute a minimal\nrequest by supplying only the required arguments.\n\nThe `services.create` method creates a Dataproc Metastore service in a\nchosen project and location. The required fields are the **parent**\nand **serviceId** fields. To create a service, supply the project number and\nlocation ID of your project for **parent** using the form\n`projects/{projectNumber}/locations/{locationId}`. And supply the service ID for\n**serviceId**.\n\n[Try It!](/dataproc-metastore/docs/reference/rest/v1/projects.locations.services/create?apix_params=%7B%22parent%22%3A%22projects%2F%7BprojectNumber%7D%2Flocations%2F%7BlocationId%7D%22%7D)\n\nThe results of the method invocation appear in a box under the **Execute**\nbutton. Typically, the box has a green header with the HTTP status code `200` in\nit, indicating the request succeeded.\n\nIf the header is red and contains an HTTP failure code, the box contains\nthe error message. See [Tips](#api-explorer-tips) for pointers on resolving\nerrors.\n\nSupply additional parameters\n----------------------------\n\nThe list of parameters you see depends on the method to which the API Explorer\nwidget is attached. The `services.create` method has more than just the\n**parent** and **serviceId** parameters, but they are the only required\nparameters.\n\nYou can use the optional **requestId** parameter to specify a unique request ID\nto allow the server to ignore the request if it has completed.\n\nUse **fields** to limit output further\n--------------------------------------\n\nBy default, the set of parameters that API Explorer shows corresponds to\nthe parameters of the associated method. However, the API Explorer widget\nalso has a set of extra fields that are not available via the method itself.\n\nThese parameters are hidden under the toggle **Show standard parameters**.\n\nClick this toggle to expose the extra widget parameters. Click\n**Hide standard parameters** to hide them from view.\n\nThe most useful of these standard parameters is the **fields** parameter, which\nlets you select the fields in the returned output that you want to see. This is\nvery useful in the API Explorer panel, where the output is displayed in a box.\nThere is often a lot of output to scroll through.\n\nTips\n----\n\nThe following sections contain API Explorer tips.\n\n### Remember to change `{projectNumber} and {locationId}`\n\nDo not forget to replace `{projectNumber} and {locationId}` with your project's\nnumber and location ID. Note that the API also accepts the project ID in place\nof the number.\n\n### Problems with the values\n\nHere are some issues to watch for when using the API Explorer forms. These\nmistakes might cause errors or might be accepted but be treated like spelling\nerrors in the API method:\n\n- Don't use quotation marks around field values of any type.\n- Be sure to quote strings appearing inside filters. Use double quotation marks (`\"`) and not apostrophes (`'`).\n- Don't use backslashes or URL-encoding in form fields. If needed, URL-encoding is performed on the field values when you execute the method.\n- Look at the value in the result box after executing the call. You might notice the problem there.\n- Supply a value for the **pageSize** field, such as `2`. This limits the amount of data that is returned as you debug your API call.\n\n### Bookmark URLs for debugging\n\nAfter you get the output you want, bookmark the API Explorer URL. When you want\nto run the method again, paste the URL into your browser. You see the form\nalready populated with your values. Make any necessary changes to the\nparameters, and click **Execute** to run the method again.\n\n### Authentication\n\nThere is a **Credentials** section on the API Explorer page, above the\n**Execute** button. You typically don't need to change anything here.\n\nThe default authentication mechanism is `Google OAuth 2.0`.\n\nThere is also a **Show scopes** toggle in the **Credentials** section. This\nshows you which Compute Engine scopes you have available. By default,\nall available scopes are enabled.\n\nWhat's next\n-----------\n\n- [Dataproc Metastore API](/dataproc-metastore/docs/reference/rest)\n- [Enable the API](/dataproc-metastore/docs/enable-service)\n- [Quickstart for deploying Dataproc Metastore](/dataproc-metastore/docs/create-service-cluster)"]]