HTTP Request not working

Hey my http request Body looks like this:

{
“user”: “test@email.com”,
“groupid”: “f_4325623525”
}

and is working in Postman.

When I’m trying to parse the post request into the body with an variable that has this content (VARIABLE1 = test
VARIABLE2 = f_4325623525) it isn’t working…:

“{”“user”" :“”" + VARIABLE1 + “@email.com” + “”“, ““groupid”” :”“” + VARIABLE2 + “”“}”

When I output it as log message it looks exactly like the requested syntax that is working in postman.

I also have the body format as “application/json”.

I get an error that the group was not found. But when I use the same post request in Postman it works…
What am I doing wrong?

Hi,

To isolate cause, can you try it without variable?
It may be better to read text file using ReadTextFile activity, then pass it to HTTP Request.
If it works, it’s matter of passing variable.
If it doesn’t work, it’s matter of settings of HTTP Request.

Regards,

Hi,

Ensure that there are no extra quotes or formatting issues. Also, make sure that the variables VARIABLE1 and VARIABLE2 are correctly populated.

you can try as below

VARIABLE1 = “test”
VARIABLE2 = “f_4325623525”

jsonString = “{”“user”“:”“” + VARIABLE1 + “@email.com”“,”“groupid”“:”“” + VARIABLE2 + “”“}”

This should produce a JSON string like {"user":"test@email.com","groupid":"f_4325623525"} , which is the format you’re looking for.

1 Like

@Tmsn

-Before constructing the JSON string, log or display the values of VARIABLE1 and VARIABLE2 to verify that they contain the expected values.
-Ensure that you are using double quotes (" ) consistently in the JSON string construction.

-Use `String.Format:

String.Format("{{\"user\":\"{0}@email.com\",\"groupid\":\"{1}\"}}", VARIABLE1, VARIABLE2)

-Ensure that the Content-Type header in your HTTP request is set to “application/json.”

Hey I have fixed the issue by deseralizing the String and creating a jObject.

Then i use the jObject.ToString as body. Now that does work.

Thanks for the replies though!