How to escape double quotes while passing body in api

Hi All …
i would need to pass the below in body for an API .

how do i do this . kindly help

{
“merchantId”: “AFuH”,
“storeId”: “AF0067”,
“userId”: “Abem”,
“type”: “mailfund”,
“amount”: “20.00”,
“currencyCode”: “GB”,
“clientSystemTransactionId”: “JTTE13”,
“accountDetails”: {
“cardTokenizedNumber”: “991001517”
}
}

If you have a VB.net language project, in the HTTP Request activity, the Body should have this format:

"{
""merchantId"": ""AFuH"",
""storeId"": ""AF0067"",
""userId"": ""Abem"",
""type"": ""mailfund"",
""amount"": ""20.00"",
""currencyCode"": ""GB"",
""clientSystemTransactionId"": ""JTTE13"",
""accountDetails"": {""cardTokenizedNumber"": ""991001517""}}"

If you have a C# language project, in the HTTP Request activity, the Body should have this format:

@"{
" + "\n" +
      @"""merchantId"": ""AFuH"",
" + "\n" +
      @"""storeId"": ""AF0067"",
" + "\n" +
      @"""userId"": ""Abem"",
" + "\n" +
      @"""type"": ""mailfund"",
" + "\n" +
      @"""amount"": ""20.00"",
" + "\n" +
      @"""currencyCode"": ""GB"",
" + "\n" +
      @"""clientSystemTransactionId"": ""JTTE13"",
" + "\n" +
      @"""accountDetails"": {
" + "\n" +
      @"""cardTokenizedNumber"": ""991001517""
" + "\n" +
      @"}
" + "\n" +
      @"}"

Let us if this Body is now accepted in Studio.

in VB: defining a JSON string -
we can use the " when escaping double quote
Or we are using single quote instead
grafik

when spanning over multiple lines then we concat the lines like

"{ ""merchantId"": ""AFuH"", " &
" ""storeId"": ""AF0067"", " &
" ....... "

In some cases we prefer to read in the JSON from a text file e.g. when it is used as a template which we want also easy to configure

Hello @tharani.natarajan, :smiley:

The best practice (and easier) to solve this problem is creating a JObject or Dictionary variable, initialize it and build it the way I did in Example.xaml

Note: Then just input the JObject as a String (Json.ToString) in the body of request. Ok? Try it!

print

Example.xaml (9.0 KB)

Thanks
for sort and simple solution

1 Like