I my workflow I am trying to post a request using Json body.
But, when I am trying to create a variable for Json body. I am getting Compiler error. Please find the screenshot below.
My Json Body Request is: {“userInfo”:{“firstName”:“John”,“lastName”:“Smith”,“address1”:“123 App Avenue”,“address2”:“Unit 123",“country”:“US”,“city”:“Denver”,“state”:“CO”,“zipCode”:“12345”,“phoneNumber”:“1231231234”,“email”:"beer@snipp.com”},“isQa”:true,“externalUniqueId”:“ID241”,“promotionIdentifier”:“100000”,“amount”:“5”,“deliveryConfiguration”:{“deliveryOptions”:{“campName":“”,“from”:"noreply@rewards.com”,“to”:“”,“senderFirstName”:“App”,“senderLastName”:“Reward”,“subject”:“Your reward”,“message”:“Congratulations”,“bccAddress”:“”,“ccAddress”:“”},“deliveryMethod”:“email”,“disableDefaultDeliveryMethod”:false,“sendReward”:true}}
Using double quote i tried to store the body into a variable.
It looks like you want to store the request into a string. So what you will need to do is embed all the inner quotes (otherwise, each new quotation either opens or closes a string). So to do this, you can sometimes just simply replace the inner quotations with a single quote. If that doesn’t work (as I am not sure), you will need to use 2 quotes for each inner quotation
Yeah, I think so. If you hover over “Body”, it will show what type it should be, like <String>. I don’t have much experience with HTTP Request activity though.
My suggestion would be to output whatever you put in the Body to a Message Box or WriteLine or Text File, so you can verify the string is correct. I’m not sure on the Body format though, cause I don’t have much experience with it. Good luck.
I tried with escaping the double quotes too. But after hitting the request, I get the error as “error:request is not valid json”.
Any insights into this? @ClaytonM@aksh1yadav
Hi @Bhaskar_Mukka,
Thanks for checking.
Following is the original Request Body, that is working fine in Postman.
{
“default_phone_number”:null,
“password”: “qwer1234”,
“email":"av@avtest.com”,
“first_name”:“AV”,
“is_admin”: true,
“last_name”:“Admin”,
“permissions”:{
“edit_apps”:true,
“edit_commcare_users”:true,
“edit_data”:true,
“edit_web_users”:true,
“view_report_list”:[
],
“view_reports”:true
},
“phone_numbers”:[
],
“role”:“Admin”,
“username":"av@avtest.com”
}
Request Body as string:
“{‘default_phone_number’:null,’password’: ‘qwer1234’,’email’:’av@avtest.com’,’first_name’:’Joe’,’is_admin’: True,’last_name’:’Admin’,’permissions’:{‘edit_apps’:True,’edit_commcare_users’:True,’edit_data’:True,’edit_web_users’:True,’view_report_list’:,’view_reports’:True},’phone_numbers’:,’role’:’Admin’,’username’:’av@avtest.com’}”