An API is considered defined after front-end and back-end configurations are completed. Next, you need to debug, test, and publish the API. After the API is published, you can make it available on Alibaba Cloud Marketplace.
In the API Gateway console, click APIs in the left-side navigation pane. On the API List page, click Manage in the Operation column corresponding to an API. Then, click Debug API in the left-side navigation pane. On the page that appears, set the request parameters to perform simple debugging operations. By default, the system calls the API in the test environment during debugging. Therefore, you must publish the API to the test environment. The following figure shows the page structure.This step can be skipped.
- Mock and non-Mock debugging methods are supported.
- If you select Mock, you must set the mock result. When you debug an API in Mock mode, the system does not directly call the back-end service. Instead, it verifies the API parameters and path addressing before accessing the back end.
- If you do not select Mock, the system directly calls the back-end service and then returns the result on the right. The result can be returned either by API Gateway or your back-end service.
What distinguishes testing from debugging is that testing simulates real API user scenarios to call APIs in the test environment. APIs in the test environment can be accessed through second-level domain names of API groups to which the APIs belong. In this case, you can perform the testing without binding independent domain names to the groups.
To simulate a real API call, you must publish the API to the test environment, create an application, and create an authorization for the application to call the API.
After the API is published to the test environment, its status becomes Running on the API List page.
Create an application.
View the application ID, which is used to search for the application.
Authorize this application to call the API. Note that authorizations are environment-specific.
- You can use the Key and Secret of the created application to simulate third-party API calls. You can find the Key and Secret on the application details page in the console. For more information, see Quick Start for API Calling.
- The application is the identity used by the API user to call the API. Each API user must create an application. For more information, see Quick Start for API Calling.
- Authorization grants an application the permission to call an API. API authorization can be completed by the API service provider or by purchasing the API from Alibaba Cloud Marketplace. For more information, see Quick Start for API Calling.
- You must prepare an independent domain name. This domain name cannot be the same as your back-end service address. However, it can be the second, third, or higher level domain name of an existing domain name.
- This domain name must be resolved to the second-level domain name of the API group. If you want to make a group of APIs available on Alibaba Cloud Marketplace, you must resolve the CNAME of the independent domain name to the second-level domain name of the API group.
- This domain name must already be ICP filed at Alibaba Cloud. If the original filing was completed by another service provider, the domain name must be transferred for ICP filing at Alibaba Cloud.
- In the API Gateway console, bind the prepared domain name to the API group.
- After you publish the API to the release environment, you can prepare the API for release on Alibaba Cloud Marketplace. See the Guide to making APIs available on Alibaba Cloud Marketplace.
- If debugging or testing fails, check whether the service address and Path configurations are correct.
- If the response is not as expected, ensure that API Gateway correctly maps the back end to the front end.
- If the API calling fails, check whether the bound independent domain name is ICP filed or transferred for ICP filing at Alibaba Cloud.
- If the API calling fails, check whether the CNAME of the bound independent domain name is resolved to the correct second-level domain name.
- If the Invalid Url error is reported during API debugging or testing, check whether the API is published to the test environment and is in the Running state.
- If the Invalid Url error is reported when you make the API available on Alibaba Cloud Marketplace, check whether the API is published to the release environment and is in the Running state.
- If the API calling does not take effect when the API definition is changed, check whether you have re-published the API.
- For APIs available on Alibaba Cloud Marketplace, you cannot select No Certification or Private.