Unicode Characters Encoding Issue .Net core

Venkatesh Kalva 1 Reputation point
2022-09-29T13:55:47.893+00:00

Hello All,

I am having an encoding Issue in .Net core Application. Here are the details:

When i submit a request through postman to my .net core web api with request body contains special characters as below (жарко). I could able to serialize them and get the response back as special characters.

Followed microsoft document:
https://learn.microsoft.com/en-us/dotnet/standard/serialization/system-text-json/character-encoding

{
"Date": "2019-08-01T00:00:00-07:00",
"TemperatureCelsius": 25,
"Summary": "жарко"
}

But when i submit the same Request using SoapUi tool, the Summary field in the request body is converting as (??????) and am unable to serialize them.
I have followed the jsonserializerOptons but did not work for me .

options = new JsonSerializerOptions
{
Encoder = JavaScriptEncoder.Create(UnicodeRanges.BasicLatin, UnicodeRanges.Cyrillic),
WriteIndented = true
};
jsonString = JsonSerializer.Serialize(weatherForecast, options);

Could someone help me, whats is happening with SoapUi request and unable to serialize it?

thanks in advance.

Developer technologies | C#
Developer technologies | C#
An object-oriented and type-safe programming language that has its roots in the C family of languages and includes support for component-oriented programming.
{count} votes

1 answer

Sort by: Most helpful
  1. Michael Taylor 61,116 Reputation points
    2022-09-29T16:13:47.023+00:00

    The issue is with SoapUI, not your API. .NET is Unicode based and therefore those characters are not going to cause any issues unless you're doing something crazy like string parsing. It appears that your SoapUI client doesn't like Unicode characters.

    Based upon the Stack Overflow post about the issue, you need to configure the encoding for the request to UTF-8.

    0 comments No comments

Your answer

Answers can be marked as 'Accepted' by the question author and 'Recommended' by moderators, which helps users know the answer solved the author's problem.