Use encoding
Sets the encoding of the request body
Function UseEncoding(Val Encoding) Export
Parameter | CLI option | Type | Required | Description |
---|---|---|---|---|
Encoding | - | String | ✔ | Encoding name |
Returns: DataProcessorObject.OPI_HTTPClient - This processor object
tip
UTF-8 is used by default
caution
NOCLI: this method is not available in CLI version
1C:Enterprise/OneScript code example
URL = "https://httpbin.org";
URL = URL + "/post";
Text = "Hello world!";
Encoding = "Windows-1251";
Result = OPI_HTTPRequests.NewRequest()
.Initialize(URL)
.UseEncoding(Encoding) // <---
.SetStringBody(Text)
.ProcessRequest("POST")
.ReturnResponseAsJSONObject();
Result
{
"args": {},
"data": "Hello world!",
"files": {},
"form": {},
"headers": {
"Accept": "*/*",
"Accept-Charset": "utf-8",
"Accept-Encoding": "gzip",
"Content-Length": "12",
"Content-Type": "text/plain; charset=Windows-1251",
"Host": "httpbin.org",
"User-Agent": "1Script v$2.0.0.0",
"X-Amzn-Trace-Id": "Root=1-68c8ad95-3aed0d6946a5ddb976d189b7"
},
"json": null,
"origin": "***",
"url": "https://httpbin.org/post"
}