0

I'm using post man code generate c# into the my code, send any request in postman and get arabic character correctly but when that code copy into my c# project with this source code:

var request = new RestRequest(Method.POST);
request.AddHeader("Content-Type", "application/json;charset=UTF-8");
request.AddHeader("Content-Encoding", "text/csv");
request.AddParameter("application/json;charset=UTF-8", "{\r\n    \"params\": {\r\n        \"auth_remoteaddr\": \"192.168.1.101\",\r\n        \"auth_type\": \"ADMIN\",\r\n        \"auth_name\": \"system\",\r\n        \"auth_session\": \"4crswevkjutd\",\r\n        \"normal_username\": \"10001084\"\r\n    },\r\n    \"method\": \"user.getUserInfo\"\r\n}", ParameterType.RequestBody);
IRestResponse response = client.Execute(request);
Console.WriteLine(response.Content);

get this response:

"name": "\u0633\u0647\u0646\u062f \u0633\u0627\u0631\u06cc \u0627\u0635\u0644\u0627"

Can't get the Arabic characters but in postman show it correct. How can I solve that problem?

Uwe Keim
  • 39,551
  • 56
  • 175
  • 291
Simi
  • 57
  • 2
  • 9
  • Seems that `\u0633` [_is_ an Arabic character](https://www.fileformat.info/info/unicode/char/0633/index.htm). – Uwe Keim Jul 13 '20 at 06:43
  • @UweKeim in post man show real arabic character for example ب but in c# restsharp not show – Simi Jul 13 '20 at 06:44
  • How can RestSharp "show" a character? After all, it is just a library for retrieving from REST APIs. Please also read "[The Absolute Minimum Every Software Developer Absolutely, Positively Must Know About Unicode and Character Sets (No Excuses!)](https://www.joelonsoftware.com/2003/10/08/the-absolute-minimum-every-software-developer-absolutely-positively-must-know-about-unicode-and-character-sets-no-excuses/)" – Uwe Keim Jul 13 '20 at 06:46
  • find my answer in this link: > https://stackoverflow.com/questions/23086825/get-json-response-using-restsharp – Simi Jul 13 '20 at 07:35

2 Answers2

0

enter image description here

When you write this sentence "Content-Type", "application/json;charset=UTF-8", seem to be good everything just you should change this point in the above picture.

Markus Meyer
  • 3,327
  • 10
  • 22
  • 35
0

After you receive the response use the below code to convert the response to object or class

var res= JsonConvert.DeserializeObject<Object>(response.Content);

note: if you convert the content json to class you replace the object type by class name like this DeserializeObject so res variable will be the data of the class.

Pradeep Kumar
  • 1,193
  • 1
  • 9
  • 21