Why does Restsharp include too many backslashes on Response.Content?

Viewed 733

I'm using Restsharp v105.2.3 on asp.net MVC.

My code below

var client = new RestClient()
client.BaseUrl = new Uri("http://sample.com/");
var request = new RestRequest("api/users", Method.GET);
request.AddHeader("Authorization", "Bearer " + token);
IRestResponse response = client.Execute(request);

return response.Content;

Instead of returning json string like this

"[{\"id\":\"1\",\"name\":\"testuser\"}]"

It adds more backslashes into the json string

"\"[{\\\"id\\\":\\\"1\\\",\\\"name\\\":\\\"testuser\\\"}]\""

Which makes deserializing difficult. I've also tested doing the same request using Postman, and it returns the json like this:

[{"id":"1","name":"testuser"}]

Why does this happen?

0 Answers
Related