Enabling gRPC server reflection will allow you to easily call your gRPC services from Postman without actually loading the protofile .
PostMan will help you test your gRPC services, by giving you the same look and feel as a you would have with a traditional HTTP API.
gRPC uses binary serialization, which means that is not human readable as JSON is. Is still possible to use grpcurl or similar tools, but you will not be able to decipher binary. Having the right tools will help you understand gRPC faster, because it has a slightly different vocabulary.
When you open PostMan and click the New button , you can choose to issue gRPC requests. Thankfully, this is not in beta anymore.
PostMan New menu options
To issue a gRPC request, you will need to specify the URL of the server (as you would do with a regular RESTful API), and then give PostMan access to the proto file that is implemented on the server. In this case, you need to help the tool a bit, so you can gain access to available functionality.
To do that you can simply import the proto file or let PostMan discover what is available.
In this case we will use the second option, because we would want our service operations to be somehow discoverable.
Different ways of 'accessing' the proto file contract
Now, if we try to click the highlighted option, we will get a big red error. This is as if our server throws an Unimplemented exception from a method.
In reality, if we look at the logs, it actually does throw that kind of exception. :)
Service 'grpc.reflection.v1alpha.ServerReflection' is unimplemented.
Enabling gRPC server reflection requires a few code tweaks because we actually need to an implementation that allows reflection over our grPC services.
Grpc.AspNetCore.Server.Reflection NuGet package. This will contain the ServerReflection implementation that will we need, that allows external services and tools to discover existing methods
Next, we need to add the middleware and then map the incoming gRPC requests to the Reflection Service.
IWebHostEnvironment env = app.Environment;
Once you did this, PostMan will successfully discover the available gRPC methods, and you will be able to call invoke these from the UI
That's it! A package and a few lines of code and you will enable gRPC server reflection.