# Where is JSON in the result givent by the code provided by postman?

**URL:** <https://community.postman.com/t/where-is-json-in-the-result-givent-by-the-code-provided-by-postman/1479>\
**Category:** Help Hub\
**Created:** [April 25, 2018, 12:08am UTC](https://community.postman.com/t/where-is-json-in-the-result-givent-by-the-code-provided-by-postman/1479 "2018-04-25T00:08:31Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Kynao](https://avatars.discourse-cdn.com/v4/letter/k/4da419/32.png) [@Kynao](https://community.postman.com/u/Kynao)\
**Post date:** [April 25, 2018, 12:08am UTC](https://community.postman.com/t/where-is-json-in-the-result-givent-by-the-code-provided-by-postman/1479/1 "2018-04-25T00:08:31Z")

</div>

Hello,

I test this url [https://api.matchbook.com/bpapi/rest/security/session](https://api.matchbook.com/bpapi/rest/security/session) with a POST and a JSON in the body containing my credentials and it works fine, i get as a result a nice JSON like this (i deleted some values in there) 🙂  
{  
“session-token”: “”,  
“user-id”: 159754,  
“role”: “USER”,  
“account”: {  
“email”: “”,  
“username”: “”,  
“balance”: 0,  
“exposure”: -0.00000505,  
“language”: “English”,  
“address”: {  
“country”: {  
“country-id”: 52,  
“name”: “”,  
“country-code”: “CUR”  
},  
“address-id”: 110199,  
“address-line-1”: “”,  
“address-line-2”: “”,  
“post-code”: “”  
},  
“currency”: “EUR”,  
“id”: 756412,  
“name”: {  
“title”: “Mr”,  
“first”: “”,  
“last”: “”,  
“title-id”: “”  
},  
“date-of-birth”: “”,  
“phone-number”: “”,  
“free-funds”: 0.00067,  
“commission-credit”: 0,  
“language-id”: 1,  
“currency-id”: 2,  
“odds-type-id”: “DECIMAL”,  
“odds-type”: “DECIMAL”,  
“bet-confirmation”: false,  
“display-p-and-l”: true,  
“exchange-type-id”: “BACKLAY”,  
“exchange-type”: “back-lay”,  
“odds-rounding”: true,  
“user-security-question”: {  
“user-security-question-id”: 71730,  
“question”: {  
“security-question-id”: 5,  
“security-question”: “”  
},  
“answer”: “”  
},  
“bet-slip-pinned”: true  
},  
“last-login”: “2018-04-24T22:22:41.000Z”  
}

This is cool until i click on code as i look for c# code and i’m given 🙂

var client = new RestClient(“[https://api.matchbook.com/bpapi/rest/security/session](https://api.matchbook.com/bpapi/rest/security/session)”);  
var request = new RestRequest(Method.POST);  
request.AddHeader(“Postman-Token”, “dcd363f4-f088-4a3a-b754-fec2272700e9”);  
request.AddHeader(“Cache-Control”, “no-cache”);  
request.AddHeader(“Content-Type”, “application/json”);  
request.AddParameter(“undefined”, “{\r\n "username": "UserNameValue",\r\n "password": "PasswordValue"\r\n}”, ParameterType.RequestBody);  
IRestResponse response = client.Execute(request);

This code works but result is not JSON. It looks like this

“{"session-token":"136170\_9f977dd3f0bdac1459296b50e3604b","user-id":458762,"role":"USER","account":{"email":"UserNameValue@mb.com","username":"UserNameValue","balance":0.00,"exposure":-0.00000505,"language":"English","address":{"country":{"country-id":52,"name":"okokok","country-code":"CUR"},"address-id":110199,"address-line-1":"Dr. M.J Hugenholtzweg","address-line-2":"Z/H. UTS- Gebouw","post-code":"12341234"},"currency":"EUR","id":754123,"name":{"title":"Mr","first":"Asian","last":"Connect NV","title-id":"MR"},"date-of-birth":"1980-01-01T05:00:00.000Z","phone-number":"1324123411","free-funds":0.00067000,"commission-credit":0E-8,"language-id":1,"currency-id":2,"odds-type-id":"DECIMAL","odds-type":"DECIMAL","bet-confirmation":false,"display-p-and-l":true,"exchange-type-id":"BACKLAY","exchange-type":"back-lay","odds-rounding":true,"user-security-question":{"user-security-question-id":71730,"question":{"security-question-id":5,"security-question":"question"},"answer":"answer"},"bet-slip-pinned":true},"last-login":"2018-04-24T22:46:54.000Z"}”

So the related c# code does not reflect what postman itself get as a result.  
Where is the JSON content? ie What do change in the code? or how to ask postman for the correct c# code?

---

<div class="post-metadata">

**Author:** ![singhsivcan](https://sea2.discourse-cdn.com/getpostman/user_avatar/community.postman.com/singhsivcan/32/1595_2.png) [@singhsivcan](https://community.postman.com/u/singhsivcan)\
**Post date:** [April 25, 2018, 7:51am UTC](https://community.postman.com/t/where-is-json-in-the-result-givent-by-the-code-provided-by-postman/1479/2 "2018-04-25T07:51:12Z")

</div>

@Kynao - Everything is perfectly fine in the code generated.  
As I can see that the result where you’re saying is not JSON is actually having extra quotes at the end and the beginning of the result.  
In the beginning, it’s like `"{"session-token...` and the end of the result is `...000Z"}"`

All you have to do is remove the extra quotes i.e. `"` from the start and the end and then it’s a valid JSON.

```auto
{
    "session-token": "136170_9f977dd3f0bdac1459296b50e3604b",
    "user-id": 458762,
    "role": "USER",
    "account": {
        "email": "UserNameValue@mb.com",
        "username": "UserNameValue",
        "balance": 0,
        "exposure": -0.00000505,
        "language": "English",
        "address": {
            "country": {
                "country-id": 52,
                "name": "okokok",
                "country-code": "CUR"
            },
            "address-id": 110199,
            "address-line-1": "Dr. M.J Hugenholtzweg",
            "address-line-2": "Z/H. UTS- Gebouw",
            "post-code": "12341234"
        },
        "currency": "EUR",
        "id": 754123,
        "name": {
            "title": "Mr",
            "first": "Asian",
            "last": "Connect NV",
            "title-id": "MR"
        },
        "date-of-birth": "1980-01-01T05:00:00.000Z",
        "phone-number": "1324123411",
        "free-funds": 0.00067,
        "commission-credit": 0,
        "language-id": 1,
        "currency-id": 2,
        "odds-type-id": "DECIMAL",
        "odds-type": "DECIMAL",
        "bet-confirmation": false,
        "display-p-and-l": true,
        "exchange-type-id": "BACKLAY",
        "exchange-type": "back-lay",
        "odds-rounding": true,
        "user-security-question": {
            "user-security-question-id": 71730,
            "question": {
                "security-question-id": 5,
                "security-question": "question"
            },
            "answer": "answer"
        },
        "bet-slip-pinned": true
    },
    "last-login": "2018-04-24T22:46:54.000Z"
}

```

---

<div class="post-metadata">

**Author:** ![Kynao](https://avatars.discourse-cdn.com/v4/letter/k/4da419/32.png) [@Kynao](https://community.postman.com/u/Kynao)\
**Post date:** [April 25, 2018, 10:36pm UTC](https://community.postman.com/t/where-is-json-in-the-result-givent-by-the-code-provided-by-postman/1479/3 "2018-04-25T22:36:35Z")

</div>

Thanks you sivcan. Yes i already tried removing quotes but given this supposed JSON :

{“session-token”:“136170\_c459f4d364f4b9253777f9ebfd53433”,“user-id”:136170,“role”:“USER”,“account”:{“email”:“Asiaconn391@mb.com”,“username”:“Asiaconn391”,“balance”:0.00,“exposure”:-0.00000505,“language”:“English”,“address”:{“country”:{“country-id”:52,“name”:“Curacao”,“country-code”:“CUR”},“address-id”:110199,“address-line-1”:“Dr. M.J Hugenholtzweg”,“address-line-2”:“Z/H. UTS- Gebouw”,“post-code”:“12341234”},“currency”:“EUR”,“id”:120247,“name”:{“title”:“Mr”,“first”:“Asian”,“last”:“Connect NV”,“title-id”:“MR”},“date-of-birth”:“1980-01-01T05:00:00.000Z”,“phone-number”:“1324123411”,“free-funds”:0.00067000,“commission-credit”:0E-8,“language-id”:1,“currency-id”:2,“odds-type-id”:“DECIMAL”,“odds-type”:“DECIMAL”,“bet-confirmation”:false,“display-p-and-l”:true,“exchange-type-id”:“BACKLAY”,“exchange-type”:“back-lay”,“odds-rounding”:true,“user-security-question”:{“user-security-question-id”:71730,“question”:{“security-question-id”:5,“security-question”:“Your favourite holiday destination?”},“answer”:“Cork”},“bet-slip-pinned”:true},“last-login”:“2018-04-25T01:31:51.000Z”}

i fullfilled into [http://json2csharp.com/](http://json2csharp.com/) and the result is : "Parsing your JSON didn’t work. Please make sure it’s valid. "

So i tried [https://app.quicktype.io/](https://app.quicktype.io/) but result is “Key must be quoted”

Also, apprenlty, i can’t give you my exact json because once i submit the string on this forum, the submitted string is transformed. The original one is full of \  
Example =\> string {\“session-token\”:\“136170\_c459f4d364f4b9253777f9ebfd53433\”,\“user-id\”: and so on

---

<div class="post-metadata">

**Author:** ![singhsivcan](https://sea2.discourse-cdn.com/getpostman/user_avatar/community.postman.com/singhsivcan/32/1595_2.png) [@singhsivcan](https://community.postman.com/u/singhsivcan)\
**Post date:** [April 26, 2018, 6:15am UTC](https://community.postman.com/t/where-is-json-in-the-result-givent-by-the-code-provided-by-postman/1479/4 "2018-04-26T06:15:09Z")

</div>

Ohhh, I guess I got your problem.

1. You can always use the three backticks like this : ``` enter code here… ``` around your code and then your code will be properly formatted when you’ll be pasting it here on the discourse.

2. Your JSON is actually stringified. Since it starts with " and ends with " also it has backslashes i.e. \ so, you definitely have a stringified JSON.  
The solution to this problem is that you’ll have to do a **JSON.parse(response)** and it should work out of the box. (This is for javascript)

Since you’re using C# then you might want to check out this resources as to how you can parse the JSON

> <https://stackoverflow.com/questions/41454690/parsing-this-kind-of-json-stringified-string-value-18>

Cheers!

---

<div class="post-metadata">

**Author:** ![Kynao](https://avatars.discourse-cdn.com/v4/letter/k/4da419/32.png) [@Kynao](https://community.postman.com/u/Kynao)\
**Post date:** [April 27, 2018, 10:46pm UTC](https://community.postman.com/t/where-is-json-in-the-result-givent-by-the-code-provided-by-postman/1479/5 "2018-04-27T22:46:43Z")

</div>

> [@singhsivcan](#):
>
> ’re using C# then you might want to check out this resources as to how you can par

Thanks you sivcan, you made it.  
I previously recorded several solutions presented in some web pages i had to investigated but you bring the one which is the easiest corresponding to this guide and it works fine [Prettifying a JSON String in .NET - Rick Strahl's Web Log](https://weblog.west-wind.com/posts/2015/mar/31/prettifying-a-json-string-in-net)
