GetResponseBody

Description

Gets the response body into a string or blob value.

It is not recommended to use this method to process large data (20 MB or 100,000 data rows can be considered as large data based on our tests).

Applies to

HTTPClient objects

Syntax

objectname.GetResponseBody ( string data )
objectname.GetResponseBody ( blob data )
objectname.GetResponseBody ( string data, encodingType )

Argument

Description

objectname

The name of the HTTPClient object for which you want to get the response body.

data

A string or blob variable into which the function returns the data.

For the string data, if the encoding charset is specified in the Content-Type response header, this function will encode the data with the specified charset; if charset is not specified, this function determines the encoding type based on the BOM header, and then converts the data into UNICODE.

encodingType

A value specifying the encoding type of the string data to be received: EncodingANSI!, EncodingUTF8!, EncodingUTF16LE!, or EncodingUTF16BE!.

If this argument is set, the encoding charset in the Content-Type response header will be ignored.


Return value

Integer.

Returns 1 if it succeeds and a negative value if an error occurs. If any argument's value is null, the method returns null.

1 -- Success

-1 -- General error

-2 -- Code conversion failed

Example

This example gets the response body and converts to a blob value:

Integer li_rc, li_StatusCode
String ls_ContentType, ls_body, ls_string
Blob lblb_blob
HttpClient lnv_HttpClient
lnv_HttpClient = Create HttpClient

// Send request using GET method
li_rc = lnv_HttpClient.SendRequest("GET", "https://demo.appeon.com/PB/webapi_client/employee/102")

// Obtain the response message
if li_rc = 1 then
 // Obtain the response status
 li_StatusCode = lnv_HttpClient.GetResponseStatusCode()
 if li_StatusCode = 200 then
  // Obtain the header
  ls_ContentType = lnv_HttpClient.GetResponseHeader("Content-Type") // Obtain the specifid header

  // Obtain the response data
  lnv_HttpClient.GetResponseBody(ls_body) // No encoding is specified, because encoding of the response data is unknown
  //lnv_HttpClient.GetResponseBody(ls_string, EncodingUTF8!) // Encoding of the response data is known to be EncodingUTF8!.
  //lnv_HttpClient.GetResponseBody(lblb_blob) // Obtain the response data and convert to a blob
  ...
 end if
end if

See also

GetResponseHeader

GetResponseHeaders

GetResponseStatusCode

GetResponseStatusText