Click here to Skip to main content
13,766,387 members
Rate this:
 
Please Sign up or sign in to vote.
See more:
Two HTTP headers are present, Content-Type:application/json and Accept:application/json

My response look like this:

"{\r\n  \"auth_token\": \"eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiJKLkRvZSIsImp0aSI6IjM5MDQ4MjllLTVjZWYtNGU4ZC1iYjZhLTNmYzI1NmFmMGNkYSIsImlhdCI6MTU0MTY3NjYxNSwiaHR0cDovL3NjaGVtYXMubWljcm9zb2Z0LmNvbS93cy8yMDA4LzA2L2lkZW50aXR5L2NsYWltcy9yb2xlIjoiTWVtYmVyIiwibmJmIjoxNTQxNjc2NjE0LCJleHAiOjE1NDE2ODM4MTQsImlzcyI6IndlYkFwaSIsImF1ZCI6Imh0dHA6Ly9sb2NhbGhvc3Q6NTYyNDkvIn0.m25YLVNdFhqOT2YsDzTADsPG1H2yoHMDDYvCOaqwl_8\",\r\n  \"expires_in\": 7200\r\n}"

Response is requested through Postman app.

Newtonsoft.Json is used to serialize and format
JsonConvert.SerializeObject(response, new JsonSerializerSettings { Formatting = Formatting.Indented });


What I have tried:

I tried this :
jwt = jwt.Replace("\"", "");


But, that solves only half of the problem, it removes only \.
Posted 8-Nov-18 1:50am
Updated 8-Nov-18 2:03am

1 solution

Rate this: bad
 
good
Please Sign up or sign in to vote.

Solution 1

There probably aren't any \r or \n in your string, they are new line codes that the text visualiser in the debugger is converting to "\r\n". If you don't want new lines in your json try using

Formatting.None


instead of

Formatting.Indented
  Permalink  
v2
Comments
1suli0 8-Nov-18 7:58am
   
Yeah, I'm aware of that, but if Indented is used, it seems that \r and \n are there, no matter what "displaying" option (Pretty, Raw or Preview) I choose in Postman. Quite confusing.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
Top Experts
Last 24hrsThis month


Advertise | Privacy | Cookies | Terms of Service
Web01-2016 | 2.8.181114.1 | Last Updated 8 Nov 2018
Copyright © CodeProject, 1999-2018
All Rights Reserved.
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100