Home > OS >  How to pass Object with multiple double quotes and raw JSON in postman
How to pass Object with multiple double quotes and raw JSON in postman

Time:09-03

I have an endpoint that is expecting an encrypted value and I am trying to test in Postman but can't figure out how to send it as it has multiple sets of double quotes. How can I properly escape the quotes so the request can be send as raw JSON in the post body.

Trying to send

{
   "data": "a:{"iv":"abcdeg1234567","encryptedData":"c37590bb7c5ce..."}"
}

If posted as above in Postman Body/raw it errors out. I have tried using \\\ or doubling up on quotes ""some value"" but it doesn't work with the object I want to send as a string.

I tried the solutions shown here: https://sqa.stackexchange.com/questions/42483/how-to-send-double-quotes-in-postman-csv-data-file but they did not work for me as I am trying to send different data.

CodePudding user response:

you json is not valid but your you can fix

{
   "data": "{\"a\" :{\"iv\":\"abcdeg1234567\",\"encryptedData\":\"c37590bb7c5ce...\"}}"
}

after this you can read data

var jp=JObject.Parse(json);
var data=JObject.Parse((string) jp["data"] );

or better

jp["data"]=JObject.Parse((string) jp["data"] );
var fixeJson=jp.ToString();

final result

{
  "data": {
    "a": {
      "iv": "abcdeg1234567",
      "encryptedData": "c37590bb7c5ce..."
    }
  }
}
  • Related