How to send json body in HTTP request for POST method

Hi All , am using HTTP request activity for API automation it’s working fine for GET method. now am unable to use the post method as json body input is giving error. it’s working fine postman tool. i tried giving that body in a string by assign activity even then also its not accepting the format.
my josn body::

{
“short_description”: “Unable To connect To office wifi”,
“description”: “Test”,
“assignment_group”: “CAB Approval”
}

Thanks and regards,
Gopinath.

1 Like

Replace all the double quotes with single quotes and send it as string…

“{
‘short_description’: ‘Unable To connect To office wifi’,
‘description’: ‘Test’,
‘assignment_group’: ‘CAB Approval’
}”

5 Likes

Thank you @HareeshMR now its taking in string format working fine.
one more thing these key values are always dynamic. i tried giving them in variable but no luck. can you please check.

“{
‘short_description’: '”+shortdes.ToString+"’,
‘description’: ‘Test’,
‘assignment_group’: ‘CAB Approval’
}"

what is the error?

Before giving it as a input to the post request, use assign activity to build the entire string, then give it as a variable to the request. So that the string built with the dynamic content.

@HareeshMRam am doing the same, using the assign activity to insert the body and passing the string . but while inserting the variable of fields like short description which are dynamic am getting this error
String comments must end with double quotes

“{
‘short_description’: '”+shortdes.ToString+"’,
‘description’: ‘Test’,
‘assignment_group’: ‘CAB Approval’
}"

Hi @gopianth,

The problem is that, the string needs to be in a single line while you are assigning it to a variable, it can’t be as the body we send in postman.

Here is the workflow PassingJsonStringFromAssign.zip (1.9 KB)

Let me know if it helps

3 Likes

Thanks @HareeshMR its working fine.:+1:

1 Like

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