The API Store has an integrated API Console using which you can read API documentation and invoke APIs. Alternatively, you can use a tool like cURL to invoke APIs.
Let's get started.
Log in to the API Store using the URL
http://<hostname>/Store?tenant=<tenant_name>and click the API that you want to subscribe to.
Click the APPLICATIONS menu and click ADD APPLICATION to create a new application.
- Give a name and a tier for the application and click Add.
Go back to the API's subscription options and select the application you just created, the Bronze tier, and click Subscribe.
When prompted, choose to view subscriptions. Then, go to the Production Keys tab and click Generate keys.
You can set a token validity period in the given text box. By default, it is set to one hour (3600 seconds). If you set a negative value (e.g., -1), the token will never expire.
However, this non-expiring token too can be revoked in some situations such as changing user password, changing the client secret, calling the token revoke api, authorization service provider detects that the tokens are compromised due to a security breach etc.
- It is not recommended to hard-code such access tokens in client's applications on any production environment to communicate with the API Manager.
- You should use the recommended methods of obtaining the token by using the relevant grant type.
- Hard coding the token needs to be done with caution and if doing so, the application needs to be provisioned to get a new token in case the current hard-coded token is invalidated by the system.
Let's invoke the API that you just subscribed to.
Install cURL if it is not there in your environment. Note that cURL comes by default in some operating systems. You can also use any other REST client.
Open the command line and execute the following cURL command:
Be sure to replace the placeholders as follows:
- <access token>: Give the token generated in step 5
<API URL>: Click the APIs menu, click the API you want to invoke and then copy the production URL in the API's Overview tab.
Then, append the payload to the production URL. E.g.,
Here's an example:
Note the result that appears on the command line.
Similarly, invoke the POST method using the following cURL command:
In this tutorial, you subscribed to an API and invoked it using cURL.