Skip to content

Request Body

KeyRunner provides different options to send request data for serving various purposes:

  1. 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 to application/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.
    • Form Data: Form data is used for submitting information via HTTP forms.

      Example:

      plaintext
      key1=value1&key2=value2

      How to Use:

      To use form data in the API client:

      • Set Content-Type: Set the Content-Type header to application/x-www-form-urlencoded.
      • Format the Data: Create a string with key-value pairs separated by & and formatted as key=value.
      • Send the Request: Include the form data string in the request payload.
    • 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 to multipart/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.
    • Raw Body: Raw body allows sending unprocessed data without any specific encoding or formatting.

      Example:

      plaintext
      This 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.
      1. GraphQL Queries

    GraphQL is a query language for APIs that enables more precise data fetching.

    Example:

    graphql
    query {
      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.
  2. GraphQL Mutations

    GraphQL mutations are used to perform write operations on the server.

    Example:

    graphql
    mutation {
      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.
  3. GraphQL Subscriptions

    GraphQL subscriptions allow clients to receive real-time data updates.

    Example:

    graphql
    subscription {
      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.

Released under the MIT License.