Executing REST calls

CSA REST API calls can be exercised through an HTTP client or programmatically from an application. The consumption API calls can also be exercised through the interactive content as explained in Using consumption API with a browser. Some calls have more strict permission requirements, administrator level permissions for example, so you will need to supply appropriate credentials.

The base URL for the Legacy API is https://<host>:<port>/csa/rest, which is appended with the specific URI for the API call. For example, to access the import API, you would use the following URL, substituting the host and port information appropriate for your environment:

https://<host>:<port>/csa/rest/import

The base URL for the Consumption API is https://<host>:<port>/csa/api, which is appended with the specific URI for the API call. For example, to access the mpp-offering API, you would use the following URL, again, substituting the host and port information appropriate for your environment:

https://<host>:<port>/csa/api/mpp-offering

Exercising API calls using an HTTP client

Though you can issue REST calls through any typical HTTP client (browser), you'll likely find it more convenient to use a client designed especially for developers making REST calls. These are often referred to as REST clients. A REST client organizes the information you'll work with when making REST calls: headers, methods, request and response bodies, and so on. A REST client makes it easier to compose and submit requests to the CSA 4.60 REST service APIs, as well as for viewing server responses.

A number of REST clients are available. You can add, for example, the REST console plug-in for Google Chrome as follows:

  • Start Google Chrome.
  • Open Chrome Web Store.
  • Use search box to search for REST Console.
  • Select Add to Chrome.

Example configuration of REST Console plug-in:

Configure the basic authorization in the Authorization tab using a user name and password. See Authentication with an integration account for more information. This user must have privileges to access CSA REST APIs.

Example REST console authorization:

When you issue a request, the output in the Response Body tab is similar to the following:

Using consumption API with a browser

In addition to being exercised programmatically or through an HTTP client, the Consumption API can be exercised through the “Try it out!” feature in the interactive API content. You will be prompted to log in to the Cloud Service Management Console to access this content. Basic authentication and authorization required to make REST calls will be configured as part of the login process.

This interactive content is presented in a web interface, and can be accessed at https://<host>:<port>/csa/apidocs.jsp from a browser, substituting the host and port information appropriate for your environment.

For example, the following sample contains calls for the component-type API:

Note API calls including “(internal use only)” in their description should not be used. These are intended for CSA product development only.

The content provides an easy access to the following information:

  • URI syntax for each call
  • Whether there are any required or optional query parameters
  • The data type of each parameter
  • Model and schema information, if applicable
  • Interactive "Try it out!" dialogs that let you submit calls to your server, see the results, and understand how you need to construct your REST URIs and any request body.

The following steps provide an example of executing an API call:

  1. If you have access to an CSA instance, launch the interactive API content from a browser at https://<host>:<port>/csa/apidocs.jsp.
  2. If you are not already logged into CSA, you will be prompted to log in. The user must have appropriate authority to exercise CSA REST calls.
  3. Locate the mpp-organization API call. Click on that the call title to expand it to show the GET method, if it is not already visible.
  4. Click on the GET method to view the complete documentation for this call.

    mpp-organization API

  5. organizationName is a required parameter. Enter an organization name from your CSA instance. You can use CONSUMER, a default organization provided out-of-the-box with CSA.
  6. Include the IdM authentication token value in the X-Auth-Token parameter.
  7. Click on the Try it out! button.
  8. You should now see the request URL that was sent, as well as the response body, response code, and response headers for your request as shown in the following figure:

Not every API call will be this simple to exercise, but this example demonstrates how the interactive API content is presented, and how REST calls can easily be made from this interface. In some situations you will need to make other API calls first to get information necessary for parameters or a request body.

Making API calls from an application

REST calls can be made from your custom application code. Preparation for making these calls is similar to making them from an HTTP client. Authentication and authorization requirements as explained in Communicate with CSA must be met.

You also need to set the HTTP headers Content-Type:application/xml or application/json, and accept:application/xml or accept:application/json as appropriate for the call you are re making.

The content type application/xml only applies to the Legacy APIs.