How do i pass a Json payload to the body of a HTTP Request

Hey everyone i have a simple json payload as such
{
“file_name”: “captcha_9.png”
} but instead of “captcha_9.png” i need to pass a variable called latest_filename is there any way i can pass it directly to the body without loading it from a text file?

Hi @tejas.ma

- Assign -> latest_filename = "your_dynamic_value"

- Assign -> jsonPayload = "{{""file_name"": """ + latest_filename + """}}"

Hope it helps!!

Thanks for the Reply!! But it still doesnt work im still getting the response Invalid Json Format

latest_filename is the String datatype variable have you passed the variable in the syntax right. If you haven’t pass it like a variable.

If it’s not working then try the below one,

- Assign -> latest_filename = "your_dynamic_value"

- Assign -> jsonPayload = $"{{""file_name"": ""{latest_filename}""}}"

Hope you understand!! @tejas.ma

Yup, this worked perfectly thanks a lot!!!

1 Like

It’s my pleasure @tejas.ma

Happy Automation!!

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.