Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

This page shows an example of Variable Insertion in Usage Engine using stream consisting of the HTTP Client function.

...

  1. Enter the JS code using the Script function. Example of a JS code snippet:

    No Format
    await push({
        url: 'https://postman-echo.com',
        foo: 42,
        bar: 'kawaboom!',
        baz: payload.value % 2,
        someData: {
            alpha: 1337,
            beta: 'foobar'
        }
    })


  2. Configure an HTTP request response in the following format. You can substitute the values of variables defined in the JS code snippet using ${variable} or @{variable}.

    Note
    titleNote!

    While configuring HTTP body, you must add the JSON objects within quotes (" ") . Applicable only for JSON objects that return value in the string format.

    Expand
    titleExample:


    Code Block
    {
    "comp": "dr",
    "dept": "pm",
    "score": 100,
    "name": "@{payload.name}",
    "age": "@{payload.age}"
    }

    You will receive the following httpResponse:

    httpResponse.json.agehttpResponse.json.comphttpResponse.json.depthttpResponse.json.namehttpResponse.json.score
    <age>drpm<name>100


    However, if you do not use " " with ${name} or ${age} or both, then you will see the httpResponse in the string format as shown below:

    httpResponse.json

    { "age": 18, "comp": "dr", "dept": "pm", "score": 100, "name": "jason" } 




...