Set data type
Sets the Content-Type of the request
Function SetDataType(Val Value) Export
Parameter | CLI option | Type | Required | Description |
---|---|---|---|---|
Value | - | String | ✔ | ContentType header value |
Returns: DataProcessorObject.OPI_HTTPClient - This processor object
tip
If the data type is not set manually, it will be matched during the process of setting the request body
caution
NOCLI: this method is not available in CLI version
1C:Enterprise/OneScript code example
URL = "https://httpbin.org";
URL = URL + "/post";
MIMEType = "text/markdown";
Result = OPI_HTTPRequests.NewRequest()
.Initialize(URL)
.SetStringBody("# Hello world!")
.SetDataType(MIMEType) // <---
.ProcessRequest("POST")
.ReturnResponseAsJSONObject();
Result
{
"args": {},
"data": "# Hello world!",
"files": {},
"form": {},
"headers": {
"Accept": "*/*",
"Accept-Charset": "utf-8",
"Accept-Encoding": "gzip",
"Content-Length": "14",
"Content-Type": "text/markdown",
"Host": "httpbin.org",
"User-Agent": "1Script v$1.9.2.10",
"X-Amzn-Trace-Id": "Root=1-682cd68a-153b5afd39db608b7ccb944c"
},
"json": null,
"origin": "***",
"url": "https://httpbin.org/post"
}