All Products
Search
Document Center

IoT Platform:InvokeDataAPIService

Last Updated:Aug 18, 2023

Calls a data analysis API operation to retrieve a SQL query result.

QPS limits

You can call this API operation up to one time per second per account.

Note

The RAM users of an Alibaba Cloud account share the quota of the account.

Debugging

OpenAPI Explorer automatically calculates the signature value. For your convenience, we recommend that you call this operation in OpenAPI Explorer. OpenAPI Explorer dynamically generates the sample code of the operation for different SDKs.

Request Parameters

Parameter

Type

Required

Example

Description

Action

String

Yes

InvokeDataAPIService

The operation that you want to perform. Set the value to InvokeDataAPIService.

ApiSrn

String

Yes

acs:iot:*:127103983461****:serveapi/device/getDeviceCountByStatus2

The globally unique identifier (GUID) of the API operation. The value of the ApiSrn parameter is returned when you call the CreateDataAPIService operation to create an API operation.

Syntax: acs:iot:*:${aliyunuserID}:serveapi/${ApiPath}.

Example: acs:iot:*:127103983461****:serveapi/device/getDeviceCountByStatus2.

Description:

  • 127103983461**** is the ID of an Alibaba Cloud account.

  • /device/getDeviceCountByStatus is the value of the ApiPath request parameter. The value is a custom portion of an API request URL.

Param.N.ParamType

String

No

VARCHAR

The data type. Valid values:

  • VARCHAR

  • INTEGER

  • BOOLEAN

  • BIGINT

  • TIMESTAMP

  • DECIMAL

  • ARRAY

Note
  • If you set the Param.N.ParamType parameter to ARRAY, the Param.N.ListParamType and Param.N.ListParamValue.N parameters take effect.

  • If you set the Param.N.ParamType parameter to other values, the Param.N.ParamValue parameter takes effect.

Param.N.ListParamValue.N

RepeatList

No

["1","2","3"]

The values of the ARRAY parameter. The array can contain only elements of the same data type. If you specify numeric values in the array, make sure that all elements are numeric values.

Note

All elements are saved as strings. IoT Platform converts the strings into a Java Database Connectivity (JDBC) object based on the value of the Param.N.ListParamType parameter.

Param.N.ListParamType

String

No

VARCHAR

The data type of parameter values.

Valid values:

  • VARCHAR

  • INTEGER

  • BIGINT

  • BOOLEAN

  • DECIMAL

  • TIMESTAMP

For more information, see JDBCType.

Param.N.ParamName

String

No

status

The name of the input parameter. This parameter value must be the same as the value that you specified for the RequestParam.N.Name parameter when you called the CreateDataAPIService operation to create an API operation.

Param.N.ParamValue

String

No

1

The value of the input parameter.

  • The value is saved as a string. IoT Platform converts the string into a JDBC object based on the value of the Param.N.ParamType parameter.

  • If you set the Param.N.ParamType parameter to ARRAY when you create an API operation, you do not need to configure the Param.N.ParamType parameter. In this case, you must configure the Param.N.ListParamType and Param.N.ListParamValue.N parameters.

IotInstanceId

String

No

iot-v64********

The ID of the instance. You can view the ID of the instance on the Overview page in the IoT Platform console.

Important
  • If your instance has an ID, you must specify the ID for this parameter. Otherwise, the call fails.

  • If no Overview page or ID is generated for your instance, you do not need to configure this parameter.

For more information, see Overview.

In addition to the preceding operation-specific request parameters, you must configure common request parameters when you call this operation. For more information about common request parameters, see Common parameters.

Response parameters

Parameter

Type

Example

Description

Code

String

Success

The error code returned if the call fails. For more information about error codes, see Error codes.

Data

Struct

The query result returned if the call is successful.

ApiSrn

String

acs:iot:*:127103983461****:serveapi/device/getDeviceCountByStatus2

The GUID of the API operation.

Example: acs:iot:*:127103983461****:serveapi/device/getDeviceCountByStatus2.

Description:

  • 127103983461**** is the ID of an Alibaba Cloud account.

  • /device/getDeviceCountByStatus is a custom portion of an API request URL.

FieldNameList

List

{"FieldNameList": ["deviceCount"]}

The list of returned fields. The value of this parameter is the same as the value that you specified for the ResponseParam.N.Name parameter when you called the CreateDataAPIService operation to create an API operation.

PageNo

Integer

0

The page number. Pages start from page 1. Default value: 1.

If you want to specify a custom page number, we recommend that you add the RequestParam.N.PageNo parameter as a request parameter to the InvokeDataAPIService operation.

PageSize

Integer

1

The number of entries per page.

If you want to specify a custom page size, we recommend that you add the RequestParam.N.PageSize parameter as a request parameter to the InvokeDataAPIService operation.

ResultList

List

[{"deviceCount": 47}]

The result of the SQL query. The value of this parameter is the same as the value that you specified for the ResponseParam.N.Name parameter when you called the CreateDataAPIService operation to create an API operation.

Description of the Map<String, Object> structure that contains list elements:

  • Key is of the String type and is the parameter name that is specified by the ResponseParam.N.Name parameter.

  • Object is the parameter value. The data type is specified by the ResponseParam.N.Type parameter.

TotalSize

Integer

12

The total number of rows in the query result.

ErrorMessage

String

The request parameters are invalid.

The error message returned if the call fails.

RequestId

String

E68FE5DC-4D7B-4987-B785-DF8C6F191F5D

The ID of the request.

Success

Boolean

true

Indicates whether the call was successful. Valid values:

  • true: The call was successful.

  • false: The call failed.

Examples

Sample requests

http(s)://iot.cn-shanghai.aliyuncs.com/? Action=InvokeDataAPIService
&ApiSrn=acs:iot:*:127103983461****:serveapi/device/getDeviceCountByStatus2
&Param.1.ParamName=status
&Param.1.ParamValue=1
&<Common request parameters>

Sample success responses

XML format

<InvokeDataAPIServiceResponse>
  <RequestId>E68FE5DC-4D7B-4987-B785-DF8C6F191F5D</RequestId>
  <Data>
        <ApiSrn>acs:iot:*:127103983461****:serveapi/device/getDeviceCountByStatus2</ApiSrn>
        <PageSize>1</PageSize>
        <PageNo>0</PageNo>
        <TotalSize>12</TotalSize>
        <FieldNameList>
              <FieldNameList>deviceCount</FieldNameList>
        </FieldNameList>
        <ResultList>
              <ResultList>
                    <deviceCount>47</deviceCount>
              </ResultList>
        </ResultList>
  </Data>
  <Success>true</Success>
</InvokeDataAPIServiceResponse>

JSON format

{
    "RequestId": "E68FE5DC-4D7B-4987-B785-DF8C6F191F5D",
    "Data": {
        "ApiSrn": "acs:iot:*:127103983461****:serveapi/device/getDeviceCountByStatus2",
        "PageSize": 1,
        "PageNo": 0,
        "TotalSize": 12,
        "FieldNameList": {
            "FieldNameList": ["deviceCount"]
        },
        "ResultList": {
            "ResultList": [{"deviceCount": 47}]
        }
    },
    "Success": true
}

Error codes.

For a list of error codes, visit the API Error Center.