Apidog

All-in-one Collaborative API Development Platform

API Design

API Documentation

API Debugging

API Mock

API Automated Testing

Sign up for free

How to Send gRPC Request with Postman

Start for free
Contents
Home / Applied skills / How to Send gRPC Request with Postman

How to Send gRPC Request with Postman

gRPC is a high-performance, open-source remote procedure call (RPC) framework that supports multiple programming languages. This article will guide you on how to send gRPC requests in Postman.

gRPC is a high-performance, open-source remote procedure call (RPC) framework that supports multiple programming languages. On the other hand, Postman is a commonly used API testing tool that supports various protocols and formats. This article will guide you on how to send gRPC requests in Postman.

What is a gRPC Request?

A gRPC request is a remote procedure call made over the gRPC protocol, which is a modern, open-source remote procedure call (RPC) framework that can efficiently connect services in and across data centers with pluggable support for load balancing, tracing, health checking, and authentication.

What Is gRPC? Definition, Architecture Pros & Cons
gRPC is an open-source Remote Procedure Call (RPC) framework developed by Google. In this article, we will explore its definition, architecture, pros, and cons, and compare it with other RPC frameworks.

Tips for Sending gRPC Requests in Postman:

Postman now supports gRPC. The request section includes the configuration required to connect to the server and execute the selected method. The request needs the server URL, service definition, and the chosen method to invoke.

Depending on the API requirements, you may have to pass message payloads, metadata, and authorization details with the request. You may also need to configure TLS and other certificates as per the requirements.

  • Server URL: gRPC URLs typically start with  grpc:// instead of http:// or https://. When creating a new request, you can also browse through the URLs you have used by selecting the URL field.
  • Method: Choose the method you want to invoke from the method selector dropdown list.
  • Payload: gRPC payloads have items that assist the server in executing the request, including:
  • Messages: Write messages in JSON format to be sent along with the request.
  • Message options: { } Use advanced formatting to present and read composite JSON messages to external users.
  • Authorization: Choose from a list of authorization types, including API Key, Basic auth, and Bearer token.
  • Metadata: Pass additional metadata with the request in key-value pairs.
  • Service definition: If the server supports server reflection, the service definition will be automatically loaded after you enter the URL. Otherwise, you will need to manually load the service definition by uploading a .proto file or creating a protobuf API in Postman.
  • TLS toggle: Unlike HTTP, where the call's execution is defined by the URL structure of whether it is performed over a secure connection or an insecure connection (http vs. https), for gRPC, the client needs to manually configure it.
  • Request actions: Options to perform actions like saving or deleting the request.

These guidelines will help you effectively send gRPC requests using Postman, leveraging its features and capabilities.

gRPC requests

gRPC allows for four different types of client-server communication modes, which can be used for different use cases:

Client-server Communication Modes
  • Unary: It is a traditional request-response communication mode also used in HTTP. The client makes a request with all the necessary details, and the server responds with a single response.
  • Client streaming: It is a client-side streaming method type where the client can send multiple message payloads, and the server responds with a single response.
  • Server streaming: It is a server-side streaming method type where the server can respond with multiple messages when the client makes a request with all the necessary details.
  • Bidirectional streaming: In bidirectional streaming, both the client and the server can communicate asynchronously by sending and receiving multiple messages.

4 Simple Steps to Send gRPC Request with Postman

Step 1: Create a gRPC Request

Open the Postman tool and click on the "New" button in the top left corner. In the popup window, select the "gRPC Request" option.

Create a gRPC Request

Step 2: Configure the Request

In the "gRPC Request" window that appears, enter the URL and method for the request.

Configure the Request

Step 3: Add Request Body

In the "gRPC Request" window, click on the "Body" tab. Here, you can add the parameters for the request.

img

Step 4: Send Request

Click the "Send" button to send the request. In the "Response" tab below, you can view the result returned by the server.

Send Request

Postman Alternative API Tool: Apidog

Using Postman to send gRPC requests is convenient and reduces debugging time. However, Postman has advanced features like Mock Server and automated testing, which require a paid subscription. Alternatively, Apidog is an emerging all-in-one API collaboration platform that offers comprehensive API management solutions.

Postman Alternative: Send gRPC Request with Apidog

Apifdoghas launched the gRPC API debugging feature, and we will demonstrate how to create a new gRPC project in Apidog and debug the interface through a sample scenario.

button

Note: The gRPC interface management feature requires Apidog version 2.3.0 or higher.

Creating a gRPC  Project in Apidog

Clicking on the "New Team" button, select the gRPC type, enter the project name, and then click on the "Create" button.

Apidog gRPC

Import .proto File

To import the .proto file that defines the gRPC API's service, methods, and messages, you can either drag and drop the file or use the file's online URL in Apidog. Then click the "Add" button.

Import .proto File

Apidog will generate the corresponding API information based on the content of the .proto file. The sample interface includes four types of method calls: Unary, Server Streaming, Client Streaming, and Bidirectional Streaming.

Initiate a Unary Call

Unary call means sending one message in a request and receiving one message in response. Compared with JSON, gRPC uses Protocol Buffers (ProtoBuf) as the default serialization framework, which can express data more compactly and improve transmission speed. In addition, gRPC uses HTTP/2 as the underlying transport protocol, applies the HPACK compression algorithm directly to process the information in the Header, reduces the size of the header in network transmission, and saves bandwidth resources. This is very friendly for scenarios that require real-time response or transmit small data.

To initiate a unary call, select the "SayHello" method and enter "grpcb.in:9000" in the API address. Then click on the "Generate Automatically" button to generate the request body and click on "Invoke" to view the response.

Initiate a Unary Call

In Apidog, you can easily extract the API address to the "Environments" so that other team members or other interfaces in the project can initiate call requests.

Environments

Server Streaming

As the icon suggests, Server Streaming means sending multiple response data in one request. For example, subscribing to all the transaction price data of stocks within one minute.

Server Streaming

Client Streaming

In this mode, the client can continuously send multiple request messages to the server without waiting for an immediate response from the server. After initiating the call, you can continuously fill in the request information in the Message and then click the "Send" button. After processing all requests, the server sends a single response message to the client.

Client Streaming

Bidirectional Streaming

Bidirectional Streaming allows clients and servers to establish persistent bidirectional communication and can transmit multiple messages at the same time. It is commonly used in online games and real-time video call software, and is suitable for real-time communication and large-scale data transmission scenarios. After initiating the call, the client and the server will maintain a session between them and receive real-time responses after sending different request contents.

Bidirectional Streaming

gRPC API Collaboration

Apidog can render gRPC interface documents that are more suitable for human reading based on .proto files, making it easier to collaborate on interfaces within a team. You can click on the menu button on the right side of the interface to get the collaboration link and share it with other team members to align the debugging method of the interface.

gRPC API Collaboration
Apidog - An integrated platform for API design, debugging, development, mock, and testing
Download the Apidog API management tool here. Perfectly compatible with macOS, Windows, and Linux. Web version is also available.