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) <noreply@anthropic.com>
This commit is contained in:
nurdotnet 2026-04-21 23:34:44 +05:00
parent 067f52cf43
commit 5d308a0538

View file

@ -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;
}