Register and publish an HTTP API so mobile clients can call your backend service through Mobile Gateway Service (MGS).
Prerequisites
Log in to the console. Under Products and Services, select Mobile PaaS.
Switch to the correct workspace and click your application name.
In the left navigation pane, choose Mobile Gateway Service.
Register an API group
Register an API group before creating and configuring an API. The group appears in the Access System section during configuration. For more information, see the screenshot in Configure the API service.
Click the API Group tab.
-
Click Create API Group and enter the following information:
Type: Select HTTP.
API Group: Required. Enter the English name of the business system.
-
Cross-VPC HTTP: Enables cross-VPC service calls when MGS and your backend are in different VPC networks.
NoteCross-VPC HTTP is only available in the Shanghai Finance region.
To enable cross-VPC HTTP, configure the following parameters:
Whether to support HTTPS: Enables MGS to forward HTTPS requests through a Server Load Balancer (SLB) HTTPS listener for data encryption. Enabled by default. Select No if HTTPS is not required.
HTTPS Domain: Required if HTTPS is enabled. The domain name of the certificate attached to the SLB instance.
VPC ID: The VPC where the Elastic Compute Service (ECS) instance is deployed, or the VPC of the SLB instance.
Instance IP or Address: The primary private IP address of the ECS instance where the service is deployed, or the IP address of the SLB instance.
-
Port Number: The service port.
ImportantMGS does not currently support self-signed certificates. Cross-VPC HTTPS requires a CA-certified domain name, or domain name resolution fails.
If you use only an ECS instance for the backend service, open the port in the ECS security group to allow traffic. For port and IP details, join DingTalk group 145930007362 and contact technical support.
Only cross-VPC access within the same region is supported. Finance and non-finance regions are treated as different regions — for example, Hangzhou Finance and Hangzhou non-finance cannot communicate.
If you use both an SLB and an ECS instance for the backend, both must be in the same VPC.
Service ERL: Required when cross-VPC HTTP is disabled. The HTTP/HTTPS URL of the business system.
Timeout: Optional. Request timeout in milliseconds. Default: 3000 ms.
-
Click Create API Group and enter the following information:
Group Type: Select HTTP. Supported types: HTTP, DUBBO, and TR.
API Group: Required. The business system name. Must start with a letter or underscore and contain only letters, numbers, underscores, and hyphens. Must match the registered API service application name.
Service Endpoint: Required. The HTTP/HTTPS URL of the business system.
Timeout: Optional. Request timeout in milliseconds. Default: 3000 ms.
Click OK to create the API group.
For full API group configuration options, see API Groups.
Create an API
On the Manage APIs tab, click Create Native API.
-
Enter the API information:
API Type: Defaults to HTTP.
Add Method: Only manual HTTP API registration is supported.
operationType: Required. A unique identifier for the API service within the current application and environment. The naming convention is
Organization.Product domain.Product.Sub_product.Operation.
Click OK to submit.
Configure the API service
On the Manage APIs tab, click Configure in the Actions column for the target API.
-
Click Edit, update the parameters, then click Save.
ImportantFor this quick start, disable Signature Verification under Advanced Configuration.
For signature verification details, see Backend signature verification.
For all configuration options, see Configure an API.
Turn on the switch in the upper-right corner to set the API service status to Enabled. Only enabled API services can be called.
Test the API service
Test your API by following API testing.
Generate a client SDK
For more information, see Generate code.
Result
The API service is now ready for client calls. Start client-side development with the following guides: