From 5d308a05385985251278fd135ab2b9e7836cc3ea Mon Sep 17 00:00:00 2001 From: nurdotnet <278048682+nurdotnet@users.noreply.github.com> Date: Tue, 21 Apr 2026 23:34:44 +0500 Subject: [PATCH] fix(moysklad): set Accept header as raw string to bypass .NET normalization The typed MediaTypeWithQualityHeaderValue API adds a space after the semicolon ("application/json; charset=utf-8"), and MoySklad rejects anything other than the exact literal "application/json;charset=utf-8" with error 1062. Co-Authored-By: Claude Opus 4.7 (1M context) --- .../Integrations/MoySklad/MoySkladClient.cs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/food-market.infrastructure/Integrations/MoySklad/MoySkladClient.cs b/src/food-market.infrastructure/Integrations/MoySklad/MoySkladClient.cs index 63cc056..a4ece45 100644 --- a/src/food-market.infrastructure/Integrations/MoySklad/MoySkladClient.cs +++ b/src/food-market.infrastructure/Integrations/MoySklad/MoySkladClient.cs @@ -33,10 +33,10 @@ private HttpRequestMessage Build(HttpMethod method, string pathAndQuery, string { var req = new HttpRequestMessage(method, pathAndQuery); req.Headers.Authorization = new AuthenticationHeaderValue("Bearer", token); - // MoySklad requires this exact Accept value (error code 1062 otherwise). - var accept = new MediaTypeWithQualityHeaderValue("application/json"); - accept.Parameters.Add(new System.Net.Http.Headers.NameValueHeaderValue("charset", "utf-8")); - req.Headers.Accept.Add(accept); + // MoySklad requires the exact literal "application/json;charset=utf-8" (no space + // after ';'). The typed MediaTypeWithQualityHeaderValue API normalizes to + // "application/json; charset=utf-8" which MoySklad rejects with code 1062. + req.Headers.TryAddWithoutValidation("Accept", "application/json;charset=utf-8"); req.Headers.AcceptEncoding.Add(new StringWithQualityHeaderValue("gzip")); return req; }