Movatterモバイル変換


[0]ホーム

URL:


Save, edit, and share gRPC request-response examples

You can save, edit, and share gRPC request-response pairs asexamples. You can even create gRPC examples from scratch.

APIs can be complex, and so can the guidelines for using them. Examples help you understand APIs by capturing the request sent from the client and the response received from the server in a single visual snapshot. You can combine these snapshots in a request and store the request in a collection to illustrate how the API functions under different scenarios. Examples help API producers tell the world beautifully what their API is about.

Saving a gRPC example

This walkthrough creates and runs a unary request, then saves the response as a gRPC example.

If you are using the Postman web app, you must use the Postman Desktop Agent. SeeAbout the Postman Agent for more information.

  1. In Postman, selectNew > gRPC to open a request in a new tab.

  2. SelectEnter Server URL and entergrpc.postman-echo.com.

  3. Select theSelect a method dropdown list. When the list of methods has loaded, selectSayHello.

    New gRPC request

  4. Save the gRPC request to a collection.

    gRPC examples can’t be saved unless the request is in a collection.

  5. SelectInvoke. Areply message appears in the response section.

  6. Selecte.g. iconSave Response. The saved example opens in a new tab and you can see the saved example under the request in the sidebar.

    gRPC Save example button

Editing a gRPC example

This walkthrough edits a gRPC example.

  1. Create a unary gRPC request, save it in a collection, and save a gRPC example.

  2. Select the gRPC example in the sidebar.

  3. In the response section, select theStatus code dropdown list and select2 UNKNOWN. The response updates automatically.

    The status codes are automatically populated based on the protobuf (protocol buffers) schema.

    Select a status code

  4. SelectSave.

Creating a gRPC example from scratch

This walkthrough uses a streaming method to create a gRPC example. Note how streaming method messages differ from unary method messages.

  1. Create a gRPC request with theLotsOfReplies method (or any streaming method) and save it in a collection.

  2. In the sidebar, hover over the gRPC request you created and select the more actions iconMore actions icon >Add example. An empty example opens in the workbench and appears below the request in the sidebar.

  3. Select theAdd a Message dropdown list and selectMessage stream. This creates a sample message stream automatically using the message structure defined in the protobuf schema.

    Select Message stream

  4. SelectSave.

Creating example-specific documentation

  1. Create a gRPC request, save it in a collection, and save a gRPC example.

  2. Select the gRPC example in the sidebar.

  3. In the right sidebar, select the documentation iconDocumentation icon.

  4. SelectAdd example description.

  5. Enter your documentation for the gRPC example. Your documentation automatically saves.

Using messages from saved examples

While invoking a request, you can work with message payloads stored in the examples. This not only enables you to test the example scenarios by yourself, but also speeds up your debugging workflow.

This walkthrough shows how you can invoke a client streaming request with messages stored in the examples:

  1. Create a gRPC request with theLotsOfGreetings method, and save it in a collection.

  2. Create an example for the request with two different"greeting" messages and save it.

    Create an example

  3. Select the request and selectInvoke.

  4. Select the dropdown list next toUse Example Message. Both messages from the example appear.

    Example messages

  5. Select a message from the dropdown list and selectSend.

  6. Open the dropdown list again and select a different message.

Last modified: 2024/06/12



[8]ページ先頭

©2009-2025 Movatter.jp