Skip to main content

Return response as string

Returns the body of the response as a string

Function ReturnResponseAsString(Val Forced = False, Val ExceptionOnError = False) Export

ParameterCLI optionTypeRequiredDescription
Forced-BooleanFalse > The processor object will be returned instead of the response if there were errors in it
ExceptionOnError-BooleanCauses an exception with a log if there were errors during processing

Returns: Arbitrary - The response or the same processing object


caution

NOCLI: this method is not available in CLI version


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

Image = "https://hut.openintegrations.dev/test_data/picture.jpg"; // URL, Path or Binary Data

Result = OPI_HTTPRequests.NewRequest()
.Initialize(URL)
.SetBinaryBody(Image)
.ProcessRequest("POST")
.ReturnResponseAsString(); // <---
Result
"{\r\n \"args\": {},\r\n \"data\": \"...\",\r\n \"files\": {},\r\n \"form\": {},\r\n \"headers\": {\r\n  \"Accept\": \"*/*\",\r\n  \"Accept-Charset\": \"utf-8\",\r\n  \"Accept-Encoding\": \"gzip\",\r\n  \"Content-Length\": \"2114023\",\r\n  \"Content-Type\": \"application/octet-stream\",\r\n  \"Host\": \"httpbin.org\",\r\n  \"User-Agent\": \"1Script v$2.0.0.0\",\r\n  \"X-Amzn-Trace-Id\": \"Root=1-68c8addb-4900c9e7161e8d425bb9aff7\"\r\n },\r\n \"json\": null,\r\n \"origin\": \"***\",\r\n \"url\": \"https://httpbin.org/post\"\r\n}"