RetrieveOne

Description

Retrieves one data row to the DataWindow, DataWindowChild, or DataStore from the RESTFul Web service.

If the data received from the RESTful web service is compressed, it will be automatically decompressed. Gzip and Brotli compression formats are supported. The developer can use the SetRequestHeader function to set the Accept-Encoding header to allow only the gzip or br compression format.

It is NOT supported 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 object

Syntax

objectname.RetrieveOne (DWControl dwObject, string urlName {,string data})

Argument

Description

objectname

A reference to the RestClient object.

dwObject

The name of the DataWindow control, DataStore, or child DataWindow.

urlName

A string whose value is the URL.

data (optional)

A string specifying the data to send to the server. If this argument is not specified, the RetrieveOne function sends the request to the server with "GET" method, otherwise with "POST".


Usage

For the RetrieveOne function, the JSON string returned from the RESTFul Web service APIs can be an array in the two-level plain JSON format (see Plain JSON: two-level structure in Application Techniques for details) or a JSON object; for the Retrieve function, the JSON string returned from the RESTFul Web service APIs must be an array in the two-level plain JSON format (see Plain JSON: two-level structure in Application Techniques for details).

If the retrieved data is a JSON object that contains one single row, the JSON object will be imported to DataWindow as one row; if the retrieved data is a JSON array that contains multiple rows, only the first element of the JSON array will be imported to DataWindow.

The RetrieveOne function is not supported in DataWindow/DataWindowChild/DataStore with the following presentation styles: Composite, Crosstab, OLE 2.0, and RichText.

Although the RetrieveOne function is not supported in the Composite DataWindow, you can call GetChild function to get the child DataWindow from the Composite DataWindow, and then call the RetrieveOne function to retrieve the data into the child DataWindow.

The RetrieveOne function is not supported for Report controls, TableBlob controls, OLE Database Blob controls, and InkPicture controls in DataWindow objects.

The RetrieveOne function is not supported for dynamically created or modified DataWindows.

AutoRetrieve for DropDownDataWindow is unsupported.

The RetrieveOne function will not pass the retrieval arguments used in computed fields and DataWindow expressions.

Return value

Long.

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

Example 1

The following code example shows the usage of RetrieveOne without the data argument.

RestClient lrc_P024
Long ll_P024_DepartmentID
Integer li_p024_RetrieveOneReturn

lrc_P024 = Create RestClient
lrc_P024.SetRequestHeaders( "Content-Type:application/json;charset=UTF-8~r~nAccept-Encoding:gzip" )

ll_P024_DepartmentID = 100

li_p024_RetrieveOneReturn=lrc_P024.RetrieveOne(dw_Data,"https://demo.appeon.com/PB/webapi_client/api/department/retrieveone/"+String(ll_P024_DepartmentID))
If li_p024_RetrieveOneReturn <> 1 Then 
//Checks if any error information
Else
 If lrc_P024.GetResponseStatusCode() <> 200 Then
  //Processes according to the exception information
 End If
End If

Example 2

The following code example shows the usage of RetrieveOne with the data argument.

RestClient lrc_P024
Integer li_p024_RetrieveOneReturn

lrc_P024 = Create RestClient
lrc_P024.SetRequestHeaders( "Content-Type:application/json;charset=UTF-8~r~nAccept-Encoding:gzip" )
 
li_p024_RetrieveOneReturn=lrc_P024.RetrieveOne(dw_Data, "https://demo.appeon.com/PB/webapi_client/department/retrievebyid", "500")
If li_p024_RetrieveOneReturn <> 1 Then 
//Checks if any error information
Else
 If lrc_P024.GetResponseStatusCode() <> 200 Then
  //Processes according to the exception information
 End If
End If

See also

Retrieve