OpenAPI Specification
If your platform team has generated an OpenAPI specification (e.g.service.openapi.yaml) as part of the build process, you can import it into tools like Swagger UI, Redoc, or Postman to explore the API interactively and see the exact request and response contracts.
To learn how to generate the OpenAPI specification file, see Generate & Distribute SDKs.
HTTP POST requests
The standard method for calling any RPC method (both Queries and Mutations) is via an HTTP POST request with a JSON body.Required Headers
When making aPOST request, you must include the following headers to indicate you are using the Connect protocol with JSON:
-
Content-Type: application/json -
Connect-Protocol-Version: 1
Endpoint URL Structure
The URL structure follows the pattern:http(s)://<host>:<port>/<package>.<Service>/<Method>
For example: http://localhost:5026/employees.v1.HrService/GetEmployeeById
Examples
Query with Arguments (POST)
Retrieve an employee by ID. The arguments are passed as a JSON object in the request body.Mutation (POST)
Mutations — operations that modify data and have side effects — must use HTTP POST.HTTP GET Requests (Caching)
GraphQL Query operations are marked as idempotent (NO_SIDE_EFFECTS) in the generated protocol buffers. This enables them to be called via HTTP GET requests.
Using GET is highly recommended for read-only operations because it allows responses to be cached by standard CDNs and browser caches, significantly improving performance.
Constructing the GET request
Since GET requests do not have a body, arguments must be passed via query parameters. The request requires three specific parameters:connect=v1: Specifies the protocol version.encoding=json: Specifies the format of the message data.message={...}: A URL-encoded JSON object containing the arguments.
Examples (GET)
Query without arguments (GET)
Retrieve all employees. The message is an empty JSON object{}.
Query with arguments (GET)
Retrieve an employee by ID. The message contains the arguments{"id": 1}.