Sending an dynamic array via json body

Anyone can replicate sending a dynamic array via json in activepieces html request (api call)?

I am trying to send a contact to a webflow membership group - that in itself is not a problem - the challenge for me is that when you asign a contact to a group in webflow then the group you added the contact to replalces all other groups the contact was in so you have to GET USER first and then get all groups and then list them like shown and thats it. In activepieces again I managed to send a one group but I am not able to dynamically make a api call to webflow.

Static applying groups would look like this:

“accessGroups”: [
“webflowers”,
“platinum”,
“free-tier”
]

For getting all existing groups(inputsmemberships) and to combine it with the new group I tried this which looks good for me but when I do the call it gets an error:

export const code = async (inputs) => {
const accessGroups = […inputs.memberships.map(group => group.slug), inputs.membership];
return accessGroups;
};

Result:
[
“bze5”,
“bze4”,
“bze2”,
“bze1”,
“bze3”,
“bze6”,
“bze7”,
]

if I send only one like this:

{
“accessGroups”: [“{{step_10[0]}}”]
}
it works fine! But if I send all groups like this

{
“accessGroups”: [“{{step_10}}”]
}
it does not work. Also removing the square brackets wont work (“Invalid request body”). And removing Quotation marks " " from {{step_10}} Like:

{
“accessGroups”: {{step_10}}
}
here activepieces wont even let me make the call, calling it “JSON Body is invalid” without the Quotation marks " "

Anyone can replicate sending a dynamic array via json in activepieces? I know a workaround that I rather not use to not make it unnesseary complex (sending it to a webapp instead of to webflow api and code the whole thing and call api from there)

Clarification is really appreciated.

Hi @bilal

Have you tried it with just the quotation marks?

{
“Key”:“value”
}

I think this should work.

Kr Bram

Again thanks Bram for looking into this, I really would like to get it to work - thought its a no brainer.

I tried this (only quotation marks) too, unfortunately it does not work - see the details in the screenshots below:

Send array with just the quotation marks (no success):

Send single item out of the array (works):

The Array:

Request Example from Webflow:

With multiple static items its as easy and working as sending just one but sending an array dynamically… either I am missing something or its not supported by the activepieces json body.

Best, Bilal

Hi @Bilal,

Sorry I miss read about the array part…

Shouldn’t the answer be:

“accessGroups”:[
“{{step_10[0]}}”,
“{{step_10[1]}}”,
“{{step_10[2]}}”
]

let me know the outcome,

KR bram

Thats not really dynamic regarding the number of groups a customer/user could have. A customer/user could have 2 groups or have 20 groups already attached. Thats why before assigning someone to a new group I have to get the groups already attached to someone - to get them all back to webflow. Whatever groups one has gets into the array via the custom-code-step now the challenge is to get them into the json body. Your Solution would work if every user would have the same amount of groups.

Thanks for looking into Bram🙏

Hi Bilal,

I have a solution for this :slight_smile:

I had similar use cases in the passed too with this, not know how many items are connected. In the below video you can see an example on how i fixed this for my job post newsletter, it’s arraying the daily jobposts.

Sorry for the crappy sound though…

0401.VBOUT daily newsletter ALL - Activepieces - Google Chrome 2024-06-26 17-40-29.mp4

let me know if this worked for you!

Kr Bram

P.S.If this doesn’t work out, you might be able to share your flow with me so I can give it a try there and then share it back with you.

1 Like

Hey Bram Big Thanks for your Video, sorry for responding late…

Anyway my problem/challenge was not getting those dynamic values together but rather send integrate them correctly in the api-call (json body). I now have found a perfectly working solution and this is by using “raw body” instead of Json - for some reason this works fine. Check the screenshot:


The custom code takes care getting the dynamic groups from the Get Member call.

Best, and again thank you for your efforts - your solution was very interesting and nice to know!
Bilal

1 Like