All Products
Search
Document Center

Mobile Platform as a Service:HTTP API

Last Updated:Jul 06, 2023

The quick start guides you to quickly register and publish an HTTP API service to be called by mobile client.

The procedure falls into 5 steps:

  1. Register API group

  2. Register API service

  3. Configure API service

  4. Test API service

  5. Generate client SDK

Preparation

  1. Log into the console, click Products and Services > mPaaS to go to mPaaS console.

  2. Choose the correct workspace, click the name of the application to access API service.

  3. On the left navigation bar, click Mobile Gateway Service to go to the mobile gateway configuration page.

Register API group

Only if you register the API group first, you can select the created API group in System when you configure the created API later.

  1. Click API group tab to open API group list, then click Create API group.

  2. In the pop-up dialog box, enter or select the corresponding information.

    Type: Select HTTP.

    API group: Required, it is the name of the business system which provides services. Start with a letter or underscore. Only letters, numbers, underscores, and hyphens are supported.

    • Cross VPC HTTP: Whether cross VPC service calls are allowed. If this switch is turned on, it means that cross VPC service calls are allowed. This feature has two different VPC network environment. One is VPC where MGS services are located, the other one is VPC deployed by the user's own service. When calling back-end services through MGS, it needs to cross VPC scenarios.

    • Note

      Currently, only the Shanghai Financial District environment provides the cross VPC HTTP function.

      To cross VPC HTTP call feature, the following configurations need to be completed:

      • Whether HTTPS is supported: MGS provides the feature to listen and forward requests from HTTPS protocol through SLB HTTPS to meet the application scenario of data encryption transmission. HTTPS is supported by default. If no HTTPS domain name is required, select No.

      • HTTPS domain name: It is only required to configure when HTTPS support is selected. It corresponds to the certificate domain name attached to the SLB.

      • VPC Id: The VPC ID of the ECS or SLB instance that corresponds to the service deployment.

      • Instance IP or Address: The primary private IP information of the ECS or the IP address of the SLB instance corresponding to the service deployment.

      • Port No.: Service port number.

        Important
        • At present, MGS does not support self signed certificates. When you cross VPC HTTPS, you need to configure the domain name of the CA certificate. If not, the domain name resolution will fail.

        • When using ECS alone to configure back-end services, you need to open the ECS security group port to avoid security policy interception. Please submit the work order to contact the technical support personnel for the relevant port IP information.

        • When you use ECS alone to configure back-end services, you need to open the ECS security group port to avoid security policy interception. For relevant port IP information, please search the group number 41708565 to join the nail group and contact the technical support personnel to obtain it.

        • Only cross VPC access in the same region is supported. Cross region VPC access is not supported. For example, services deployed in Hangzhou cannot call services in Shanghai. At the same time, financial zones and non-financial zones are divided geographically. For example, Hangzhou Financial Zone and Hangzhou Non financial Zone are regarded as different regions.

        • When you configure backend services by using SLB and ECS at the same time, you need to ensure that SLB and ECS are in the same VPC. The ECS VPC information deployed by the service is consistent with the network information of the SLB instance.

    • Host: It is the business system’s HTTP/HTTPS URL. This item needs to be configured when the cross VPC HTTP feature is not enabled.

    • Timeout period: Optional, it is the timeout period (in ms) for sending requests to the business system. It defaults to 3,000 ms.

  3. Click Create API group, and then you need to fill the information in the blank.

    • Group type: Choose HTTP. MGS supports HTTP, DUBBO and TR.

    • API group: Required, it is the name of business system of providing the service. It starts with a letter or underscore. It only allows letters, numbers, underscores, and hyphens. The API group name should be consistent with the registered API service APP name.

    • Host: Required, It is the business system’s HTTP/HTTPS URL.

    • Timeout period: Optional, it is the timeout period (in ms) for sending requests to the business system. It defaults to 3,000 ms.

  4. Click OK to submit. To complete the configuration of API group, see Configure HTTP group.

Register API service

  1. Click Manage APIs tab to open API list, then click Create API.

  2. In the pop-up dialog box, enter or select the API information.

    • API type: Select HTTP.

    • Add mode: Currently, mPaaS supports manual HTTP API registration only.

    • operationType: Required, it is the unique identifier of the API service in the current workspace and application. The naming rule is organization.product domain.product.sub-product.operation.

  3. Click OK to submit.

Configure API service

  1. In Manage APIs tab, click Configure in the operation column of API list to go to API configuration page.

  2. In API configuration page, click Edit on the corresponding area to edit, and then click Save.

  3. Turn the switch on the top right corner to switch API service to On. (Only the API services turned On can be called.)

Test API service

See Test API for more information.

Generate client SDK

See Generate codes for more information.

Result

After completing the steps above, API service can be called by client.

For more detailed information of client development, see Client development guide: