Concatenate items does not work as expected, preview is different to output

Describe the problem/error/question

I’m using the lists node to concatenate items from a JSON object. The original object contains a set of SKUs and Quantities and I just want the list of SKUs so I can submit these to an API call.

In the preview the SKUs are shown wrapped in double quotes, but when the body of the call is sent, there are no double quotes, so it is invalid JSON.

It doesn’t make any difference if I include “Raw value” or “values” on the Lists node.

Please share your workflow

Hey @CraigCooperXYZ,

Welcome to the community :cake:

It loosk like the UI is trying to be helpful, Try using {{ JSON.stringify($json["SKUS"]) }} instead which will output the array rather than the string version. This change means your body content will be something like…

{
  "request": {
    "SKUS": {{ JSON.stringify($json["SKUS"]) }},
  }
}

While will result in the below being sent…

{
  "request": {
    "SKUS": ["0103-BLU-1012","0103-BLU-1416","0103-BLU-1820","0103-BLU-2224","0103-BLU-2628","0103-BLU-3032","0103-LIL-1012","0103-LIL-1416","0103-LIL-1820","0103-LIL-2224","0103-LIL-2628","0103-LIL-3032"],
  }
}

Here is the updated workflow as well.

4 Likes

Thanks for your help Jon.

That worked perfectly. I’m still getting to grips with what I can and can’t use in expressions in terms of JS.

2 Likes

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.