Recently I have been made aware of people asking advice about using the API Connect v10 REST-APIs and the API Connect v10 apic/apic-slim Toolkit, so I thought I would try to help inexperienced users with some accelerator tips...
1. First, for the API Connect v10 Toolkit
- Obviously getting started with the Toolkit is detailed here: https://www.ibm.com/docs/en/api-connect/10.0.1.x?topic=applications-working-toolkit
- One good tip I saw from @Chris Dudley recently was:
use `--format json` or `--format yaml` on all CLI commands as you will get far more content back, both when commands are successful and when errors occur
- Secondly, when using the Toolkit commands if you want to see the REST call(s) that the Toolkit uses to carry out the tasks add --debug to the end of the Toolkit call and the REST call will be in the output, and then you can use that REST call without using the Toolkit.
- And finally for the Toolkit here is a resource for commands that you might need to use: https://github.com/ibm-apiconnect/example-toolkit-scripts
2. Now, to make REST API calls instead you need to do the following:
- Set a client_id and a client_secret (one-off task)
- Which realm do you need to use? (decide for each API call)
- Generate a Bearer_token using realm, username, password, client_id and client_secret (token lasts 8 hours by default)
- Use the generated Bearer_token to call a REST API
Going through each of these in turn:
- How do you set a client_id and a client_secret?
Create an App to set these: https://apic-api.apiconnect.ibmcloud.com/v10/#/documentation/authentication/auth_clientid_secret
Also this is a useful supplemental guide too: https://chrisphillips-cminion.github.io/apiconnect/2019/09/20/RegistringAppsToUseTheAPICCLI.html
(NB: you can also use REST calls to create the App.)
- How do you select which realm do you need to use?
Provider Org / Catalog / Space level calls need access from the provider realm.
Cloud level calls need the admin realm access.
You can see how to list the realms for your system here: https://apic-api.apiconnect.ibmcloud.com/v10/#/documentation/authentication/auth_bearertoken
- Generating a Bearer_token using realm, username, password, client_id and client_secret:
This is explained here: https://apic-api.apiconnect.ibmcloud.com/v10/#/documentation/authentication/auth_bearertoken
- Now you are ready to use the Bearer_token to call the REST APIs:
Provider APIs: https://apic-api.apiconnect.ibmcloud.com/v10/#/IBMAPIConnectPlatformProviderAPI_200/overview
Cloud APIs: https://apic-api.apiconnect.ibmcloud.com/v10/#/IBMAPIConnectPlatformCloudManagementAPI_200/overview
Analytics APIs: https://apic-api.apiconnect.ibmcloud.com/v10/#/IBMAPIConnectAnalyticsAPI_200/overview
And also some tips that might help you:
- Tip for selecting REST calls?
See Toolkit section regarding using --debug to extract the REST call from a Toolkit command
- Next tip for REST calls: still struggling to decide which call you need to use?
You can use the API Manager UI or Cloud Manager UI to extract the REST call for a task by setting your Browser to use Developer Tools - Network (F12) and so by carrying out a task in the UI you can see the call being used in the output.
Then you can go back to https://apic-api.apiconnect.ibmcloud.com/v10 and find the call being used and see all the parameters etc. available for that call to fine tune it to your specific needs.#APIConnect
I hope you find this useful!
API Connect Consultant
IBM Hybrid Cloud Integration Expert Labs
IBM UK Ltd