Skip to main content
Best answer

How to replace string values in array?


Hey!
I want to replace the string values into an array and send to the webhook.

 

That's what I'm doing:

1 step. I get a string with values separated by commas

 

2 step. I use “Code by Zapier” for split by “, ” and creating an array

And this is work!

 

3 step. Send this Array to Webhook

 

As a result, this is what I get

[
  {
    "like2": "Variant 5,\nVariant 4,\nVariant 3"
  }
]

 

But I need to get it in a different form, with this

{
    "like2": ["Variant 5", "Variant 4", "Variant 3"]
}
  1. I want array only from value
  2. I also want to delete the "\n"

Please help me how to do this?

Best answer by Troy TessaloneBest answer by Troy Tessalone

Hi @Paul87 

Try this…

Code

 

POST Webhook

 

Webhook Trigger

 

View original
Did this topic help you find an answer to your question?
This post has been closed for comments. Please create a new post if you need help or have a question about this topic.

5 replies

  • Author
  • New
  • 2 replies
  • August 22, 2021

Can not understand.
If in the last step I send a webhook and specify two parameters. The first is what should be an array after processing ”Code by Zapier”. The second is the string data.

 

Why are exactly the same parameters sent in fact?

 

 

 


Troy Tessalone
Forum|alt.badge.img+14

Hi @Paul87 

You need to remove the line breaks (\n) in the Code step.

 


Troy Tessalone
Forum|alt.badge.img+14
  • Zapier Expert
  • 30916 replies
  • Answer
  • August 22, 2021

Hi @Paul87 

Try this…

Code

 

POST Webhook

 

Webhook Trigger

 


  • Author
  • New
  • 2 replies
  • August 22, 2021

Hi @Troy Tessalone 

Thanks! It works, but… 

This is what i get

Zapier adds quotes around array when trying to send this in webhoock. As a result, not a true data array is transmitted, but just text :(


Troy Tessalone
Forum|alt.badge.img+14

@Paul87

It’s unclear where you are getting that recent screenshot from.

If you use a POST Webhook and set a data point to the array as shown, it will work.