Skip to main content

Return response as binary data

Returns the response body as binary data

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

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

Returns: Arbitrary - The response or the same processing object


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

Image = "https://api.athenaeum.digital/test_data/picture.jpg"; // URL, Path or Binary Data

Result = OPI_HTTPRequests.NewRequest()
.Initialize(URL)
.SetBinaryBody(Image)
.ProcessRequest("POST")
.ReturnResponseAsBinaryData(); // <---
Result
NOT JSON: 7B 0A 20 20 22 61 72 67 73 22 3A 20 7B 7D 2C 20 0A 20 20 22 64 61 74 61 22 3A 20 22 64 61 74 61 3A 61 70 70 6C 69 63 61 74 69 6F 6E 2F 6F 63 74 65 74 2D 73 74 72 65 61 6D 3B 62 61 73 65 36 34