You can interactively test a managed API created for a REST API in a Swagger interface. You can view the API URL, the HTTP status codes, the request parameters, and the response parameters. You can also execute the API for testing purposes, or get a sample cURL command.
In the
API Registry
page, click to select a managed API, or click to open the Actions menu and select
View API Details
.
The API details window appears.
Select the
Swagger
tab.
If the managed API requires authentication, the
Authorization
dialog box appears. You might need to perform one of the following actions based on the authentication type that the managed API uses:
If the managed API uses JSON Web Token (JWT) authentication, no action is required.
API Manager
generates a JWT token and authenticates to the managed API.
If the managed API doesn't use JWT authentication and uses basic authentication, enter the username and password of a user who is authorized to access the managed API.
If the managed API uses only OAuth 2.0 authentication, enter the credentials of an OAuth 2.0 client that allows access to the managed API.
To expand the view in the
Swagger
tab, click the arrows in the upper right corner.
To view the API request body and response codes, click any button that displays an API method.
For example, for an API with a POST method, a
POST
button is displayed. Click the
POST
button to view the API request body and response code. The input fields are displayed in the request body and the output fields are displayed in the response body with the data types and field descriptions.
To view the request body in JSON format, select
application/json
. To view the request body in XML format, select
application/xml
.
To test the API semantics, in the request body panel, perform the following steps:
Click
Try it out
.
Edit the request body. Replace any parameter type with a value.
If a query parameter in a managed API URL includes spaces, the access request fails. Use
POST
to pass a query parameter that includes spaces.
To test the updated request body, click
Execute
.
The
Server response
panel displays the response body, response headers, and request duration time.
To clear the server response, click
Clear
.
To cancel the request body changes, click
Cancel
. To change the request body again, click
Edit
.
To view the request or response syntax, in the
Models
panel, click the right arrow near the request or response entry.
The model request or response body is displayed. A red asterisk next to an element indicates a required element. The input fields are displayed in the request body and the output fields are displayed in the response body with the data types and field descriptions.