Back to Tooljet

Pass Values in a REST API Query

docs/versioned_docs/version-2.50.0-LTS/how-to/pass-values-in-rest-api.md

3.20.154-lts2.1 KB
Original Source

This guide gives you an overview of how you can pass values in a REST API Query using raw JSON and key-value pairs.

<div style={{paddingTop:'24px'}}>

Raw JSON

In the following JSON code, the ${} syntax is used for JavaScript string interpolation within template literals (also called template strings). This allows dynamic values from JavaScript variables or expressions to be injected directly into the string.

javascript
{{
  `{
     "contents": [{
       "parts": [{
         "text": "Generate the following content for this image in markdown format:
            content type: ${components.typeOfContentInput.value},
            additional info: ${components.additionalInfoInput.value}"
        },
        {
            "inline_data": {
              "mime_type":"image/jpeg",
              "data": "${components.imageUploader.file[0].base64Data}"
            }
          },],
      },],
    }`
  }}
<div style={{textAlign: 'center'}}> </div> </div> <div style={{paddingTop:'24px'}}>

Entering Key Value Pairs

In this example, simple key-value pairs are entered in the provided input fields. Here, the values can simply be passed using double curly braces as is typically done in ToolJet. Take note of the status key. A string is combined with another value that is referred using double curly braces.

<div style={{textAlign: 'center'}}> </div> </div>

To see REST API queries in action, check out the following tutorials:

  1. Gemini AI Content Generator
  2. Open AI Audio Transcriber