Calls a specified service of a device.

Limits

  • If you synchronously call a service, the maximum timeout period is 5 seconds. If the server does not receive a response within 5 seconds, a timeout error occurs. If you asynchronously call a service, no timeout limit exists.
  • Each Alibaba Cloud account can run a maximum of 500 queries per second (QPS).
    Note 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 InvokeThingService

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

Args String Yes {"param1":1}

The input parameter of the service. The value is a JSON string. Example: Args={"param1": 1}.

If you do not need to specify this parameter, set the value to Args={}.

Identifier String Yes Set

The identifier of the service. You can view the service identifier in the IoT Platform console. Go to the Define Feature tab of the Product Details page. You can also call the QueryThingModel operation and view the service identifier in the returned TSL data.

IotInstanceId String No iot_instc_pu****_c*-v64********

The ID of the instance. This parameter is not required for public instances. However, the parameter is required for the instances that you have purchased.

IotId String No Q7uOhVRdZRRlDnTLv****00100

The ID of the device. The device ID is issued by IoT Platform.

Note If you specify this parameter, you do not need to specify the ProductKey or DeviceName parameter. The IotId parameter is a globally unique identifier (GUID), and corresponds to a combination of the ProductKey and DeviceName parameters.

If you specify the IotId parameter and a combination of the ProductKey and DeviceName parameters at the same time, the IotId parameter is used.

ProductKey String No a1BwAGV****

The ProductKey of the product to which the device belongs.

Note If you specify this parameter, you must also specify the DeviceName parameter.
DeviceName String No light

The DeviceName of the product to which the device belongs.

Note If you specify this parameter, you must also specify the ProductKey parameter.

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

Response parameters

Parameter Type Example Description
Code String iot.system.SystemException

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

Data Struct

The data returned if the call is successful.

MessageId String abcabcabc1234****

The ID of the message. IoT Platform sends the message to the device to call the service.

Result String {"param1":1}

The result of the synchronous call.

This parameter is not returned if the service is asynchronously called.

ErrorMessage String A system exception occurred.

The error message returned if the call fails.

RequestId String E55E50B7-40EE-4B6B-8BBE-D3ED55CCF565

The ID of the request.

Success Boolean true

Indicates whether the call was successful.

  • true: The call was successful.
  • false: The call failed.

Examples

Sample requests

https://iot.cn-shanghai.aliyuncs.com/?Action=InvokeThingService
&ProductKey=a1BwAGV****
&DeviceName=device1
&Identifier=service1
&Args=%7B%22param1%22%3A1%7D
&<Common request parameters>

Sample success responses

XML format

<InvokeThingServiceResponse>
  <Data>
        <Result>{"code":200,"data":{},"id":"100686","message":"success","version":"1.0"}</Result>
        <MessageId>abcabc123</MessageId>
  </Data>
  <RequestId>A44C818E-FA7F-4765-B1E7-01D14AE01C6A</RequestId>
  <Success>true</Success>
</InvokeThingServiceResponse>

JSON format

{
  "Data": {
    "Result": "{\"code\":200,\"data\":{},\"id\":\"100686\",\"message\":\"success\",\"version\":\"1.0\"}", 
    "MessageId": "abcabc123"
  }, 
  "RequestId": "A44C818E-FA7F-4765-B1E7-01D14AE01C6A", 
  "Success": true
}

Error codes

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