Managing Custom APIs in Applications
Scenario
If you need to call a custom API on the frontend page (such as an advanced page), you can view the URL and other information of the custom API on the custom API page.

Viewing Custom APIs
- Log in to the Huawei Cloud Astro Zero console and click Access Homepage. The application development page is displayed.
- In the upper left corner of the page, click
and choose Environments > Environment Configuration.
- Choose Maintenance from the main menu.
- In the navigation pane, choose Global Elements > CCustom APIs to view all custom APIs.
- Click an operation name in the custom API list to view the API details.
Table 1 Parameters on the API details page Parameter
Description
Label
Label configured when a custom API is created.
Operation Name
Name configured when a custom API is created.
Version
API version.
Category
Category to which an API belongs.
Allow Anonymous Access
Indicates whether the API can be accessed anonymously in the runtime environment.
If this parameter is selected, anonymous access is allowed. If no valid token authentication information is available when you access the API using the subdomain name of the running environment, you can access the API as an anonymous user with the Anonymous User Profile permission. CSRF verification is not required for anonymous user access. For example, add a service permission credential required by the API to Anonymous User Profile to access the API anonymously using the subdomain name of the runtime environment.
For example, the URL of the login API (used to log in to applications) is /service/Namespace__MyApp/1.0.0/login, and the subdomain name of the runtime environment is test.example.com. Allow Anonymous Access is selected for this API. If the API's service permission credential is configured for Anonymous User Profile, anonymous users can access the API through https://test.example.com/service/Namespace__MyApp/1.0.0/login.
When configuring anonymous access, comply with the following rules:
- If an account needs to support anonymous access to the custom API, the subdomain name of the runtime environment must be set.
- A custom API that allows anonymous access is preferentially accessed with valid authentication profiles.
- CSRF verification is not required for anonymous users to access custom APIs.
- Regardless of the access mode, profile verification after identity authentication is the same. If the API has service permission credentials, the system checks whether the user profile has the credentials.
Deprecated
Whether the API is discarded.
Description
API description.
Created Date
Time when a custom API is created.
Last Modified By
User who last modified the custom API.
Last Modified Date
Last time when the custom API is modified.
API Type
API type.
Method
Method, such as GET, PUT, POST, or DELETE, to be called after the mapping.
URL
URL of the API. You can click
next to the URL to copy the URL and configure the URL to call the API.
Type
- Flow: indicates that a flow is called through this API.
- Script: indicates that a script is called through this API.
- Object: indicates that the custom URL is used to operate object data, including adding, deleting, modifying, and querying object data.
Resource
Name of the called flow, script, or name of the operated object.
Content Type
Body type in a request.
- application/json
- multipart/from-data
- binary-data
multipart/from-data and binary-data are used by the file upload API. If either of them is selected, only POST scripts can be called.
Custom Response
Indicates whether to format the response returned after the URL is called. If this option is selected, the response is formatted. The resCode, resMsg, and result outer information is deleted, and only the returned messages are transparently transmitted.
- If Custom Response is not selected, the following response is returned:
{ "resCode": "0", "resMsg": "Success", "result": [ { "equipments": [ { "createdBy": "aaa", "createdBy.__objectType": "User" }, { "createdBy": "aaa", "createdBy.__objectType": "User" } ], "total": "2" } ] }
- If Custom Response is selected, only the following response is returned:
{ "equipments": [ { "createdBy": "aaa", "createdBy.__objectType": "User" }, { "createdBy": "aaa", "createdBy.__objectType": "User" } ], "total": "2" }
Compatible Mode
- If this option is selected, the compatibility mode of versions earlier than Huawei Cloud Astro Zero 1.3.6 is used to encapsulate an array based on the output structure.
- Deselected: The output structure is not encapsulated.
Service Permissions Credential
Click Edit to add a service permission credential for the API.
- Preview and test an API.
- On the custom API list, click
in the row of the API to review the API.
If the API is a public API, you can view API parameters and perform online tests. If the API is a private API, you can view only the input and output parameters of the API.
- Click
next to the API URL to view the API parameters.
If the API is a public API, click the try button, set input parameters, and click the execution button to run the API. If a success response is returned, the custom API is called successfully.
Figure 2 Viewing the returned result
- On the custom API list, click
Feedback
Was this page helpful?
Provide feedbackThank you very much for your feedback. We will continue working to improve the documentation.See the reply and handling status in My Cloud VOC.
For any further questions, feel free to contact us through the chatbot.
Chatbot