Request Body
KeyRunner provides different options to send request data for serving various purposes:
Request Data:
JSON Body: The JSON body is commonly used for sending structured data in API requests.
Example:
json{ "key1": "value1", "key2": "value2" }
How to Use:
To use the JSON body in the API client:
- Specify Content-Type: Set the
Content-Type
header toapplication/json
. - Construct the Body: Create a JSON object with key-value pairs representing the data to be sent.
- Send the Request: Include the JSON body in the request payload.
- Specify Content-Type: Set the
Form Data: Form data is used for submitting information via HTTP forms.
Example:
plaintextkey1=value1&key2=value2
How to Use:
To use form data in the API client:
- Set Content-Type: Set the
Content-Type
header toapplication/x-www-form-urlencoded
. - Format the Data: Create a string with key-value pairs separated by
&
and formatted askey=value
. - Send the Request: Include the form data string in the request payload.
- Set Content-Type: Set the
Multipart Form: Multipart form data allows the transmission of non-textual data (e.g., files) along with textual key-value pairs.
Example:
plaintext--boundary Content-Disposition: form-data; name="text_field" Text Value --boundary Content-Disposition: form-data; name="file_field"; filename="example.txt" Content-Type: text/plain File content goes here... --boundary--
How to Use:
To use multipart form data in the API client:
- Set Content-Type: Set the
Content-Type
header tomultipart/form-data; boundary=<boundary>
. - Construct the Payload: Create a multipart message with each part separated by the defined boundary.
- Send the Request: Include the multipart form data in the request payload.
- Set Content-Type: Set the
Raw Body: Raw body allows sending unprocessed data without any specific encoding or formatting.
Example:
plaintextThis is a raw body content.
How to Use:
To use raw body content in the API client:
- Set Content-Type: Set the appropriate
Content-Type
header based on the data being sent. - Provide Raw Content: Insert the raw data as the request payload without any additional formatting.
- Send the Request: Transmit the request with the raw body content.
- GraphQL Queries
- Set Content-Type: Set the appropriate
GraphQL is a query language for APIs that enables more precise data fetching.
Example:
graphqlquery { user(id: "123") { name email } }
How to Use:
To use GraphQL queries in the API client:
- Define Query: Write a GraphQL query specifying the required fields and arguments.
- Send the Request: Transmit the query to the GraphQL endpoint via an HTTP POST request.
- Set Headers: Include necessary headers like
Content-Type: application/json
.
GraphQL Mutations
GraphQL mutations are used to perform write operations on the server.
Example:
graphqlmutation { createUser(input: { name: "Alice", email: "alice@example.com" }) { id name email } }
How to Use:
To use GraphQL mutations in the API client:
- Construct Mutation: Create a mutation specifying the operation and required input fields.
- Send the Request: Transmit the mutation to the GraphQL endpoint using an HTTP POST request.
- Set Headers: Include necessary headers like
Content-Type: application/json
.
GraphQL Subscriptions
GraphQL subscriptions allow clients to receive real-time data updates.
Example:
graphqlsubscription { newPosts { id title content } }
How to Use:
To use GraphQL subscriptions in the API client:
- Define Subscription: Create a subscription specifying the data to be received.
- Establish Connection: Connect to the GraphQL subscription endpoint using WebSockets or other supported protocols.
- Handle Data: Receive and process the real-time data updates.