Web request - start Json Body with square bracket

Hi all,
sorry if this could be a stupid question, I have been working with EasyMorph for 2 days.

I need to have a Json body starting and closing with square brackets, but I didn’t find a way to do this, as the json form automatically opens and closes with curly brackets.

Is there a way?

Thank you so much
Claudio

Hi Claudio and welcome to the Community forum!

How do you produce the JSON body? Do you use the “Construct JSON” action in EasyMorph, or somehow else?

Hi Dmitry and nice to meet you again!

No, actually not yet, now I tried with “Costruct JSON” and I understood this action create an array and so I have the square brackets.

Thanks! Now I have to use the result of my Construct JSON into my web request body, am I right?

Thank you
Claudio

Yes, that's correct. The result of Construct JSON would be a 1-row table (if no grouping applied). You can use the "Iterate web request" action as it allows assigning request body from a column in EasyMorph. Since the table has only 1 row, the "Iterate web request" action will send only 1 request which will make it similar to the regular "Web request" action.

It works! Thank you Dmitry for your help.

Hi Dmitry,
the “Construct JSON” works perfectly and create the array as I need, but when I send the request with “Iterate Web Request” if I use json content-type (mandatory for my request), the request starts always with curly brackets. This is not good for me.


Do you have any solution for this?
Thank you so much
Cla

Aha, I see. I think instead of Iterate + Web Request in a module you should just use the “Iterate Web Request” action right in the main module without any additional iteration or module.

You’re using the “Iterate Web Request” action in the “JSON” mode. The mode constructs a JSON and that’s why you see your argument wrapped in curly braces. But you already have the JSON constructed! Therefore you should use the “Iterate Web Request” action in the “Column” mode in the main module (where you constructed the JSON).

image

Yes, if I use column the format is perfect, but unfortunately the request failed, as the method I use needs json and with column the content-type is text.
(I also check with Postman, I need to use a Json content)

Is there a way to force the content-type?

thanks

You’re almost there! Don’t give up yet.

Just add the Content-Type header in the Headers tab:

Ahhhhhhh, yes. it was really really simple! Sorry Dmitry, but thank you so much for your help!

You’re welcome! :slight_smile: