SendGetRequest
PowerScript function
Description
Sends the HTTP GET request to the server and then gets the content
of the server response. It does not parse the HTTP response code and
content of the server response.
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
RESTClient objects
Syntax
|
1 |
objectname.SendGetRequest(string urlName, ref string response) |
|
Argument |
Description |
|---|---|
|
objectname |
The name of the RESTClient object from which you want to |
|
urlName |
A string value specifying the URL. |
|
response |
The content of the server response. If RESTClient failed to send request or server provides no |
Return value
Integer. Returns 1 if the function 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 — Invalid URL
-3 — Cannot connect to the Internet
-4 — Timeout
-7 — Failed to decompress data
-10 — The token is invalid or has expired
-14 — Code conversion failed
-15 — Unsupported character set
Example
The following example shows the usage of SendGetRequest.
|
1 2 3 4 5 6 7 8 9 10 11 12 13 |
RestClient lrc_P019 String ls_P019_ResPonse lrc_P019 = Create RestClient //Sets the request header to return a gzip package lrc_P019.SetRequestHeaders("Content-Type:application/json;charset=UTF-8~r~nAccept-Encoding:gzip") lrc_P019.SendGetRequest('https://demo.appeon.com/PB/webapi_client/api/department/retrieve', ls_P019_ResPonse) If lrc_P019.GetResponseStatusCode() = 200 Then //Column name and type between dw_Data the returned JSON string ls_P019_ResPonse must match. dw_Data.ImportJson( ls_P019_ResPonse) Else //Checks if any error according to the value of ResponseStatuscode and ls_Response End If |
See also