Skip to main content

Set Form body

Sets the body to x-www-form-urlencoded from a collection of field values

Function SetFormBody(Val Data) Export

ParameterCLI optionTypeRequiredDescription
Data-ArbitraryKeyValue collection with form parameters

Returns: DataProcessorObject.OPI_HTTPClient - Set Form body


caution

NOCLI: this method is not available in CLI version


1C:Enterprise/OneScript code example
    URL = "https://httpbin.org";
URL = URL + "/post";

Data = New Structure("Field1,Field2", "10", "Text");

Result = OPI_HTTPRequests.NewRequest()
.Initialize(URL)
.SetFormBody(Data) // <---
.ProcessRequest("POST")
.ReturnResponseAsJSONObject();
Result
{
"args": {},
"data": "",
"files": {},
"form": {
"Field1": "10",
"Field2": "Text"
},
"headers": {
"Accept": "*/*",
"Accept-Charset": "utf-8",
"Accept-Encoding": "gzip",
"Content-Length": "21",
"Content-Type": "application/x-www-form-urlencoded; charset=utf-8",
"Host": "httpbin.org",
"User-Agent": "1Script v$1.9.2.10",
"X-Amzn-Trace-Id": "Root=1-682cd6a1-2230e2f11fe4c5db5430028c"
},
"json": null,
"origin": "***",
"url": "https://httpbin.org/post"
}