Reviewing REST API integration
The BIRT iHub server offers many RESTful URI endpoints to access stored resources on the server. This example uses Objective-C to make the following REST API requests:
*Authenticate the user to receive an authentication ID to attach to other REST API requests.
*Download a list of locations values that are used to build BIRT reports.
*Download data sets in JSON format for display in third-party visualizations.
Using Objective-C for iOS, a RESTful URI request to a resource is built using the NSString class. NSURLConnection sends the NSString to the iHub server.
An NSDictionary object is created from the iHub server’s JSON formatted response using the NSJSONSerialization class. The Objective-C code uses these NSDictionary values to request additional resources, display available location names in a table, and to display data about a location in a text string or an embedded visualization such as a chart.
Using the Android SDK for Android mobile devices, you can select from multiple HTTP client libraries to make a RESTful URI request, such as the HttpClient from the Apache HTTPComponents project or Java’s HttpURLConnection class. After making an HTTP request to a URI endpoint and checking for errors, the response from the iHub server is assigned to a string for additional processing.
The following REST API operations are used in BIRT Gazetteer:
*/Login
Used in BIRTLoginViewController.m to return an authId for an authenticated user.
*/Files
Used in BIRTBarChartViewController.m and BIRTMasterViewController.m to retrieve a file id by searching for the file name.
*/Visuals
Used in BIRTBarChartViewController.m to search for bookmark names in a BIRT file.
*/Dataobject
Used in BIRTColumnChartViewController.m and BIRTMasterViewController.m to extract values from a data set in a selected data store file.