cancel
Showing results forย 
Search instead forย 
Did you mean:ย 

Build json body- for POST request

npise
New Contributor II

How to build raw POST body using mapper? Need to achieve below

{
โ€œconditionsโ€: [
{
โ€œnameโ€: โ€œlearningevent_idโ€,
โ€œoperatorโ€: โ€œ==โ€,
โ€œvalueโ€: โ€œ12345โ€
}
]
}

I am able to achieve image its missing [ ]

Expression for mapper below
image

1 ACCEPTED SOLUTION

dimitri_hristov
Contributor

Hi @npise,

You could put sl.ensureArray($requestBody.conditions) in an expression in a Mapper after the one you described, and assign it to the $requestBody.conditions target path.

Alternatively, if you want to achieve everything in one Mapper, you can put sl.ensureArray({}.extend({name:โ€œlearningevent_idโ€, operator:โ€œ==โ€,value:$learningevent_id})) in the expression and assign it to the $requestBody.conditions target path.

BR,
Dimitri

View solution in original post

2 REPLIES 2

dimitri_hristov
Contributor

Hi @npise,

You could put sl.ensureArray($requestBody.conditions) in an expression in a Mapper after the one you described, and assign it to the $requestBody.conditions target path.

Alternatively, if you want to achieve everything in one Mapper, you can put sl.ensureArray({}.extend({name:โ€œlearningevent_idโ€, operator:โ€œ==โ€,value:$learningevent_id})) in the expression and assign it to the $requestBody.conditions target path.

BR,
Dimitri

Thank you so much this worked!!

i was able to achieve that in one input expression
sl.ensureArray({}.extend({name:โ€˜learningevent_idโ€™, operator:โ€œ==โ€,value:$learningevent_id}))