Easyread
Published in

Easyread

Testing your GRPC using Postman

Step by step testing GRPC using Postman

Grpc using postman

Postman is an application used for API testing. It is an HTTP client that tests HTTP requests, utilizing a graphical user interface, through which we obtain different types of responses that need to be subsequently validated.

In this tutorial i’ll explain how to testing our GRPC services using postman. In this example we will using golang to create our simple hello world services.

Postman Version

Make sure your postman is version v9.7.1+ or you can download from here

Install golang

Here i’m using go version go1.16.9 darwin/amd64

golang version

Install golang dependency

Install protobuf module by using command go get

go get google.golang.org/protobuf/runtime/protoimpl@v1.26.0
go get google.golang.org/protobuf/reflect/protoreflect@v1.26.0
install protobuf dependency

Create Golang file and Go mod

Create new folder called go-simple-grpc or whatever you want and create new file main.go.

Also create go module by typing go mod init golang/simple-grpc.

go mod init golang/simple-grpc

Create proto file

now we will create new folder called proto and create proto file called hello.proto and paste this example to your file.

So now project directory will like this

project directory

Generate protobuf file

Now we will generate protocol buffer wo our project, first go to your project in terminal

go to project directory in terminal

Eventually execute this command from here, this will generate implementation of protocol buffer you can see details in here

protoc --go_out=. --go_opt=paths=source_relative --go-grpc_out=. --go-grpc_opt=paths=source_relative ./proto/*.proto

so our project directory will be like this.

generated proto files

Fill main.go file

Now fill main.go with this code, this code will implement grpc services based on our proto file

grpc implementation main.go

now we can run our grpc service in terminal, now type go run main.go in our terminal like this. Now our services is running 🚀🚀

run our grpc service

Testing in postman

Now we will test our hello service in postman, open our postman and create new request

create new request in postman

Now click on grpc request

click grpc request

Eventually fill this value like this, then upload our local proto to postman

server url: localhost:9090
import grpc file to postman

Then filling detail our proto file like this, it will saved in our postman api later.

schema        : Protobuf 3
name : HelloService
version name : 1.0.0
proto file detail

Next is choose method that we want to test in HelloService which is SayHello method.

choose method to test

Lasthing is filling our payload to send to our grpc service like this

{
"name": "Hello world"
}
grpc payload

Then click invoke button in postman and boom 💥 , we get our response in postman.

response from our grpc server service

So simple isn’t ?, we can also test for another method in our HelloService same as like above method.

Reference

--

--

--

Easy read, easy understanding. A good writing is a writing that can be understood in easy ways

Recommended from Medium

Improving my Software Engineering knowledge with the giants

How to implement a simple gRPC service using Golang

LeetCode — Longest Common Sequences

Happy Birthday Dune Network !

PortSwigger: SQL injection attack, querying the database type and version on MySQL and Microsoft

PortSwigger: SQL injection attack, querying the database type and version on MySQL and Microsoft

6| How to fail in a Construction project

GitHub Students Developer Pack (By GitHub Education)

Building Resilia Academy With Contentful

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Ferdina Kusumah

Ferdina Kusumah

Backend Software Engineer

More from Medium

How to install Go on Apple M1 MacBook?

Small Go package style (part 1)

Application of channels in Golang

Redis to REST, securely