REST Plugin Output Configuration

When I was building a workflow today, my teammates showed me a super handy way to make use of the Output configuration in the REST plugin (something I didn’t even realize was there).

In my workflow I used the REST plugin to make an API call and get some data. The JSON response looked something like this:

{
   "posts": [
      {
        "id": 237,
        "more_data": "blah"
      },
      {
        "id": 468,
        "more_data": "more blah"
      }
  ],
  "type": "test",
  "answer": "yes"
}

All I wanted from this data was the posts list, because I wanted to loop over it and do something with each post. I wasn’t sure how to extract that list without a Python step or something else, but it turns out you can do this in the “Output” section of the REST plugin.

If you’re editing your REST step in your workflow, you can scroll down, click on the little Edit icon beside Output, and you’ll get something like this:

image1

This allows you to customize the schema of the JSON object that is output from the API call. What that means is you can add variables that match those within your JSON, and then they’ll be available for use elsewhere as variables throughout your workflow. Here’s what I did for mine:

image2

What it’s doing is creating a new variable based on my original JSON object (aka the body_object). The name of it in my JSON is posts, so that’s what I’ve called it here, and it’s an array of objects (you can see that in my example payload above).

So I save my REST step with that configured, then I go to configure my loop, since I want to loop over the list of posts. And you can see that the posts variable I configured in my REST step is now available for selection here. Previously this was not the case.

image3

That’s super handy. Now I can loop over it as I wanted to, and I didn’t have to use a Python step or anything else to extract the posts list from the JSON in my REST step.

3 Likes