HTTP Request - How to use variable inside JSON body

Hi Experts,
I am sending the request with the following JSON body which works fine for me without any issues.
“{
‘name’: ‘XYZ Test company pvt ltd’,
‘regionalName’: ‘ME’,
‘code’: ‘H01’
}”

But question here is, how to use variable inside JSON body to parameterize.
In Assign activity, NewCompanyName=“XYZ Test company pvt ltd”
and then, I try to use the variable NewCompanyName inside JSON body as like below.
“{
‘name’: ‘+NewCompanyName+’,
‘regionalName’: ‘ME’,
‘code’: ‘H01’
}”

I am getting the following error when I execute after used variable in JSON body
Agency ID:{“isError”:true,“detail”:null,“errors”:[{“code”:7009,“message”:“Unexpected character encountered while parsing value: \. Path ‘name’, line 2, position 13.”},{“code”:7009,“message”:“Bad JSON escape sequence: \+. Path ‘name’, line 2, position 16.”}]}

Could some experts help me to sort out this?

Thanks!

Hi,

You need to double all “. For example:
“{”“is error””:"""+strMyVariable+"""}"

except for the 1st and last one as you can see above. So when you add a variable, you need three ".

Good luck

Thanks a lot Melanie

It works now.