Buf(1) Buf(1) NAME buf-curl - Invoke an RPC endpoint, a la 'cURL' SYNOPSIS buf curl [flags] DESCRIPTION This command helps you invoke HTTP RPC endpoints on a server that uses gRPC or Connect. By default, server reflection is used, unless the --reflect flag is set to false. Without server reflection, a --schema flag must be provided to indicate the Protobuf schema for the method being invoked. The only positional argument is the URL of the RPC method to invoke. The name of the method to invoke comes from the last two path components of the URL, which should be the fully-qualified service name and method name, respectively. The URL can use either http or https as the scheme. If http is used then HTTP 1.1 will be used unless the --http2-prior-knowledge flag is set. If https is used then HTTP/2 will be preferred during protocol negotiation and HTTP 1.1 used only if the server does not support HTTP/2. The default RPC protocol used will be Connect. To use a different protocol (gRPC or gRPC-Web), use the --protocol flag. Note that the gRPC protocol cannot be used with HTTP 1.1. The input request is specified via the -d or --data flag. If absent, an empty request is sent. If the flag value starts with an at-sign (@), then the rest of the flag value is interpreted as a filename from which to read the request body. If that filename is just a dash (-), then the request body is read from stdin. The request body is a JSON document that contains the JSON formatted request message. If the RPC method being invoked is a client-streaming method, the request body may consist of multiple JSON values, appended to one another. Multiple JSON documents should usually be separated by whitespace, though this is not strictly required unless the request message type has a custom JSON representation that is not a JSON object. Request metadata (i.e. headers) are defined using -H or --header flags. The flag value is in "name: value" format. But if it starts with an at- sign (@), the rest of the value is interpreted as a filename from which headers are read, each on a separate line. If the filename is just a dash (-), then the headers are read from stdin. If headers and the request body are both to be read from the same file (or both read from stdin), the file must include headers first, then a blank line, and then the request body. Examples: Issue a unary RPC to a plain-text (i.e. "h2c") gRPC server, where the schema for the service is in a Buf module in the current directory, using an empty request message: $ buf curl --schema . --protocol grpc --http2-prior-knowledge \ http://localhost:20202/foo.bar.v1.FooService/DoSomething Issue an RPC to a Connect server, where the schema comes from the Buf Schema Registry, using a request that is defined as a command-line argument: $ buf curl --schema buf.build/connectrpc/eliza \ --data '{"name": "Bob Loblaw"}' \ https://demo.connectrpc.com/connectrpc.eliza.v1.ElizaService/Introduce Issue a unary RPC to a server that supports reflection, with verbose output: $ buf curl --data '{"sentence": "I am not feeling well."}' -v \ https://demo.connectrpc.com/connectrpc.eliza.v1.ElizaService/Say Issue a client-streaming RPC to a gRPC-web server that supports reflection, where custom headers and request data are both in a heredoc: $ buf curl --data @- --header @- --protocol grpcweb \ https://demo.connectrpc.com/connectrpc.eliza.v1.ElizaService/Converse \ <