byteOrderMark error after update libraries

Hi.
We have clients that send a request where “byteOrderMark: true”, after updating SS libraries from 5.0.0 -> 5.5.0 these clients get an error, please tell me how can I restore the old behavior?

"ResponseStatus":{"ErrorCode":"SerializationException","Message":"Type definitions should start with a '{', expecting serialized type 'MD5_Get', got string starting with:  { \"input\":\"123456\" }","StackTrace":"   в ServiceStack.Text.Common.DeserializeTypeRefJson.StringToType(ReadOnlySpan`1 strType, TypeConfig typeConfig, EmptyCtorDelegate ctorFn, KeyValuePair`2[] typeAccessors)\r\n   в ServiceStack.Text.Common.DeserializeType`1.StringToTypeContext.DeserializeJson(ReadOnlySpan`1 value)\r\n   в ServiceStack.Text.Json.JsonReader.<>c__DisplayClass3_0.<GetParseSpanFn>b__0(ReadOnlySpan`1 v)\r\n   в ServiceStack.Text.JsonSerializer.DeserializeFromSpan(Type type, ReadOnlySpan`1 value)\r\n   в ServiceStack.Text.DefaultMemory.Deserialize(MemoryStream ms, Boolean fromPool, Type type, DeserializeStringSpanDelegate deserializer)\r\n   в ServiceStack.Text.DefaultMemory.<DeserializeAsync>d__34.MoveNext()\r\n--- Конец трассировка стека из предыдущего расположения, где возникло исключение ---\r\n   в System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)\r\n   в System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)\r\n   в ServiceStack.Host.RestHandler.<CreateRequestAsync>d__16.MoveNext()\r\n--- Конец трассировка стека из предыдущего расположения, где возникло исключение ---\r\n   в System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)\r\n   в System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)\r\n   в ServiceStack.Host.RestHandler.<CreateRequestAsync>d__15.MoveNext()\r\n--- Конец трассировка стека из предыдущего расположения, где возникло исключение ---\r\n   в System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)\r\n   в System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)\r\n   в ServiceStack.Host.RestHandler.<ProcessRequestAsync>d__14.MoveNext()"}}

tried these options but they did not help:

HttpUtils.UseEncoding = PclExport.Instance.GetUTF8Encoding(true);
JsConfig.UTF8Encoding = new System.Text.UTF8Encoding(true);

and this

SetConfig(new HostConfig { EnableOptimizations = false });

Please provide the code that you’re using to send a request with a BOM.

Oh, this is a client 1C enterprise :grinning:

HTTPRequest = Новый HTTPRequest("/md5?format=json");
HTTPRequest.SetBodyFromString(Request, TextEncoding.UTF8, ByteOrderMarkUsage.Use);

ByteOrderMarkUsage.Use is default value.

Its request raw, is ByteOrderMarkUsage.Use then first the request body is added 0xEF 0xBB 0xBF

Raw in base64:
UE9TVCBodHRwOi8vbG9jYWxob3N0OjE1NjcxL01ENT9mb3JtYXQ9anNvbiBIVFRQLzEuMQ0KSG9zdDogbG9jYWxob3N0OjE1NjcxDQpQcm94eS1BdXRob3JpemF0aW9uOiBOVExNIFRsUk1UVk5UVUFBQkFBQUFCN0lJb2drQUNRQTNBQUFBRHdBUEFDZ0FBQUFLQUxwSEFBQUFEMFJGVTB0VVQxQXRTVFZCVWpGUFRWZFBVa3RIVWs5VlVBPT0NClVzZXItQWdlbnQ6IDFDK0VudGVycHJpc2UvOC4zDQpBY2NlcHQ6ICovKg0KQ29ubmVjdGlvbjogS2VlcC1BbGl2ZQ0KQ29udGVudC1UeXBlOiBhcHBsaWNhdGlvbi9qc29uDQpDb250ZW50LUxlbmd0aDogMjMNCg0K77u/eyAiaW5wdXQiOiIxMjM0NTYiIH0=

I think I need something but for json:

SetConfig(new HostConfig {
 XmlWriterSettings = new XmlWriterSettings
    {
        Encoding = new UTF8Encoding(encoderShouldEmitUTF8Identifier: false),
    }
})

The UTF-8 BOM should now be stripped from this commit, this change is available from v5.5.1 that’s now available on MyGet.

Thanks Demis, Im update, but is not helped :unamused: :

Did you clear out your NuGet packages cache?

1 Like

did not help, I tried to clear the cache :unamused:

Can you try again with the latest version on MyGet?

Thank you very much Demis! finally it worked! :grinning: :+1: