5

I have a POST endpoint in my Java service that expects a protobuf 3 payload. This service is used by other services which send the protobuf payload. I would like to do some debugging and send a protobuf payload to the service via a curl command, however, I have no idea how to construct such a payload, given it's a binary protocol.

user4184113
  • 976
  • 2
  • 11
  • 29

1 Answers1

2

You can use protoCURL for this purpose. It's a command-line tool to send and receive protobuf HTTP REST requests while writing them in the Protobuf Text or JSON format.

A request could look something like this:

protocurl -I path/to/protos -i ..MyRequest -o ..MyResponse \
  -u http://host/path/o/endpoint -d 'someField: "some-string", someIntField: 42'

And the response may look like this:

=========================== Request Text     =========================== >>>
someField: "my-string"
someIntField: 42
=========================== Response Text    =========================== <<<
someResponseField: "The answer for everything!"
someOtherResonseMessage: {
  fooEnum: BAR
}

You can find more examples for how to use it in the repository.

(Disclaimer: I am the author of this tool and created it, because I had the same problem and needed a better tool.)