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:
parent
067f52cf43
commit
5d308a0538
|
|
@ -33,10 +33,10 @@ private HttpRequestMessage Build(HttpMethod method, string pathAndQuery, string
|
||||||
{
|
{
|
||||||
var req = new HttpRequestMessage(method, pathAndQuery);
|
var req = new HttpRequestMessage(method, pathAndQuery);
|
||||||
req.Headers.Authorization = new AuthenticationHeaderValue("Bearer", token);
|
req.Headers.Authorization = new AuthenticationHeaderValue("Bearer", token);
|
||||||
// MoySklad requires this exact Accept value (error code 1062 otherwise).
|
// MoySklad requires the exact literal "application/json;charset=utf-8" (no space
|
||||||
var accept = new MediaTypeWithQualityHeaderValue("application/json");
|
// after ';'). The typed MediaTypeWithQualityHeaderValue API normalizes to
|
||||||
accept.Parameters.Add(new System.Net.Http.Headers.NameValueHeaderValue("charset", "utf-8"));
|
// "application/json; charset=utf-8" which MoySklad rejects with code 1062.
|
||||||
req.Headers.Accept.Add(accept);
|
req.Headers.TryAddWithoutValidation("Accept", "application/json;charset=utf-8");
|
||||||
req.Headers.AcceptEncoding.Add(new StringWithQualityHeaderValue("gzip"));
|
req.Headers.AcceptEncoding.Add(new StringWithQualityHeaderValue("gzip"));
|
||||||
return req;
|
return req;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue