How to run a HTTP request with multiple body elements?

Hi there,

I have a HTTP node with JSON Body parameter. In the below you can see the body parameter.

{
“Filter”: [
{
“SKU”:“576791”,
“OutputSelector”: [“SKU”,“Name”,“WarehouseLocations”,“DefaultPrice”,“Images”]

}

]

}

In this body parameter, I want to change the SKU value.

This is the value format that I am getting from previous node. Is there anyway that I can remove " , " from the data and set a single SKU value to the body. Need to update the Body parameter SKU according to the number of SKUs there

It looks like your topic is missing some important information. Could you provide the following if applicable.

  • n8n version:
  • Database (default: SQLite):
  • n8n EXECUTIONS_PROCESS setting (default: own, main):
  • Running n8n via (Docker, npm, n8n cloud, desktop app):
  • Operating system:
  • n8n version: 1.22.4
    **Database - SQLite
    n8n EXECUTIONS_PROCESS setting - Own
    Running n8n via - Docker
  • Operating system: Windows

@AmilaDeshan , is your goal to have "576791" instead of "576791", "64MLH904"?

If so, place the whole body in the expression, and use $json["skUs"].toString().split(',')[0] as the value of SKU. Something like this

{{
  {
    "Filter": [
      {
        "SKU": $json["skUs"].toString().split(',')[0],
        "OutputSelector": ["SKU","Name","WarehouseLocations","DefaultPrice","Images"]
      }
    ]
  }
}}

Hi
Thank you for the response. But I want to get 576791 this for the first Iteration and the second Iteration I want to get 64MLH904 this.

If the SKUs field has 5 skus, I want to set each and every SKU every time and get the HTTP output according to the SKU.

@AmilaDeshan , here’s how to convert your string SKU list into an array and then split the SKU into a separate item which you can merge with your filter item and this have your filter composed for each of the items.

Below is the first half of the workflow only in case I am still misunderstanding what your original SKU string looks like. If it is an array to start with, then it even easier. Just split it out into separated SKU items.

2 Likes

Thank you very much

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