Click here to Skip to main content
15,895,462 members
Please Sign up or sign in to vote.
1.00/5 (1 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
Updated 8-Nov-18 1:03am

1 solution

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
 
Share this answer
 
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.
Ted Lowell 31-Jul-19 14:43pm    
Did you ever figure this out? I'm getting the exact same response in Postman. If I use .Indented, it has the "\r\n" and "\" and if I use .None it has just the "\"... But even if I try to use Replace on the json it still returns the "\". Any help is appreciated.

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



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900