Licensed Materials - Property of IBM
© Copyright IBM Corp. 2010
US Government Users Restricted Rights - Use, duplication or disclosure restricted by GSA ADP Schedule Contract with IBM Corp.
The Tool for ReST API exploration (referred to as 'the tool' below) is a simple utility and sample provided to support developers working with the REST API in WebSphere Business Events. It comes in the form of a Web page written using HTML and JavaScript, and runs in Mozilla-based browsers from the file system of a client computer. You can use it to issue predefined or custom HTTP requests to the API and to examine the response headers and body.
To use the tool, download the Tool for ReST API exploration SupportPac (which these instructions should appear in). The tool consists of the files restTool.html and restTool.css. For information about SupportPacs, see WebSphere Business Events Support.
When you open the file restTool.html in a mozilla based browser (such as Firefox 3.0.15), a web page similar to this screen capture is displayed:
There are two usage modes: issue predefined requests, or issue custom requests.
Predefined requests can be selected in the drop-down list that appears at the top of the page. The predefined requests assume that WBE is installed locally, and cover certain key queries and operations you may wish to perform. Each selection describes the request that will be issued. Note however that the selection is provided as a starting point for working with the REST API, and is not comprehensive. You may wish to modify the underlying HTML and JavaScript to include your own requests, or to target a particular remote WBE instance.
After selecting a predefined request, the subsequent fields will be populated with values to issue the request. Some predefined requests require a request body to be sent to the REST API - check the Request Body field for request specific instructions.
To issue a custom request, enter the URI of the REST resource you want to target and the HTTP verb you want to issue, then set values for Content-Type and Accept HTTP headers. You can also provide a body for the request by pasting character data into the Request Body field.
When you open the tool, the default field values will cause the current contents of the runtime repository to be returned as unsorted JSON list.
Full instructions for using the REST API in WebSphere Business Events can be found via the information center.
Click the button at the bottom of the page to issue the request. A page, similar to the screen capture shown here, is displayed:
This message is displayed because JavaScript code in the web page requests permission to issue requests to servers other than the server where page was loaded from, which is the local file system in this case. Cross-site requests are typically prevented by Web browsers as a security measure to prevent cross-site scripting attacks. Allow the request, if you are happy to grant the permission, and the REST request is sent to the target URI.
You may also be prompted by the browser for security credentials if the target server is secured, for example using HTTP basic authentication.
When it receives the response, the tool displays the URI that was targeted along with the HTTP status code and text. The HTTP headers and response body are also displayed, so you can see exactly how the server responded.
The tool leaves the HTTP response body unformatted so that the displayed data matches the response data as closely as possible. You may wish to use other tools to improve the readability of the data - there are several online JSON formatters that could be used, for example.
Notes: