Edit JSON from webhook to provide back in response
My goal is to edit the JSON data from a webhook to provide in webhook response.
The data is in a collection, and the number of records in the collection can vary.
Webhook data:
[
{
"data": {
"variable": {
"var": 123,
},
"urls": {
"https://website.com/page1": "https://website.com/page1",
"https://website.com/page2": "https://website.com/page2"
}
}
}
]
Formatted data to provide back in response:
{
"data": {
"https://website.com/page1": "https://website.com/page1?var=123",
"https://website.com/page2": "https://website.com/page2?var=123"
}
}
Unsure which modules I need to use between webhook & response,
I beleive I the modules I need after webhook are,
- Set variable: var = data.variable.var
- Iterator: data.urls
- Text Parser Replace: using regex to append the variable? (This is were im running into issues)
- Aggregate or Create JSON
- Webhook response
Any ideas?
data.urls
is not an array. Are you sure, because we wonât be able to iterate that (a collection).
Perhaps you can provide a screenshot of how this data looks like in the scenario, as well as providing the output bundle containing the source JSON?
Please provide the output bundles of the modules by running the scenario (or get from the scenario History tab), then click the white speech bubble on the top-right of each module and select âDownload input/output bundlesâ.
A.
Save each bundle contents in your text editor as a bundle.txt
file, and upload it here into this discussion thread.
Uploading them here will look like this:
module-1-output-bundle.txt (12.3 KB)
B.
If you are unable to upload files on this forum, alternatively you can paste the formatted bundles in this manner:
-
Either add three backticks ```
before and after the code, like this:
```
input/output bundle content goes here
```
-
Or use the format code button in the editor:
Providing the input/output bundles will allow others to replicate what is going on in the scenario even if they do not use the external service.
This will allow others to better assist you. Thanks!
samliew â request private consultation
Join the Make Fans Discord server to chat with other makers!
1 Like
Thanks!
This is webhook data
[
{
"data": [
"https://website.com/page1",
"https://website.com/page2"
],
"meta": {
"variable": {
"var": 123
},
"urls": {
"https://website.com/page1": "https://website.com/page1",
"https://website.com/page2": "https://website.com/page2"
}
}
}
]
This is the formatted response I want to generate
{
"data": {
"https://website.com/page1": "https://website.com/page1?var=123",
"https://website.com/page2": "https://website.com/page2?var=123"
}
}
The number of records in urls can vary.
Hi @Bryant_Chang , hope you are doing well.
I have created a scenario to try this please check out
I am using the json module with the output you shared.
Then I created a âSet Variableâ Module to convert the collection (meta.urls) into array using toArray() function.
In 3rd step I used an iterator module to iterate through the array to get the items into separate bundles.
In 4th step I used a text aggregator module to map the urls as response (text). You can use the âtextâ result as webhook response.
Here are the screenshots -
2 Likes
Amazing. Thank you!
This worked for me!
1 Like
Glad it helped @Bryant_Chang . Thank you for marking this as solution. I am very new to Make and still learning. This is my first solution in the forum. I am really motivated.
Take care.
2 Likes