GetResponseBody
PowerScript function
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
Syntax
|
1 |
objectname.GetResponseBody ( string data ) |
|
1 |
objectname.GetResponseBody ( blob data ) |
|
1 |
objectname.GetResponseBody ( string data, encodingType ) |
|
Argument |
Description |
|---|---|
|
objectname |
The name of the HTTPClient object for which you want to |
|
data |
A string or blob variable into which the function returns For the string data, if the encoding charset is specified |
|
encodingType |
A value specifying the encoding type of the string data to If this argument is set, the encoding charset in the |
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:
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 |
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