Call this operation to run a specified service on a specified device.

Request Parameters

Parameter Type Required Description
Action String Yes The operation that you want to perform. Set the value to InvokeThingService.
IotId String No

Device ID. The unique identifier of a device.

Note If you use this parameter, ProductKey and DeviceName are not required. IotId is a globally unique identifier (GUID), and corresponds to a combination of ProductKey and DeviceName. If you specify both IotId and the combination of ProductKey and DeviceName, the system follows IotId. Empty parameters are not allowed in requests.
ProductKey String No

The ProductKey of the device.

Note If you use this parameter, DeviceName is required.
DeviceName String No

The name of the device.

Note If you use this parameter, ProductKey is required.
Identifier String Yes The identifier of the service that you want to call. You can view the Identifier of a service in the TSL of the product on the Define Feature page of the product in the IoT Platform console.
Args String Yes The input parameter data of the service . The data format is JSON string, for example, Args={"param1":1}. If the service has not any input parameter, you must pass in this parameter as Args={} . For information about Args, see the following table Args.
Common Request Parameters - Yes See Common parameters.
Table 1. Args
Parameter Type Description
key String

The identifier of an input parameter, which you defined when you were defining the service.

On the Define Feature page of a product in the IoT Platform console, you can view all the input parameters of services in the TSL of the product, or click the Edit button of a service to view the defined input parameters of this service.

value Object Specify a value. This specified value must be in the defined value range of the input parameter.

Response parameters

Parameter Type Description
RequestId String The globally unique ID generated by Alibaba Cloud for the request.
Success Boolean Indicates whether the call is successful. A value of true indicates that the call is successful. A value of false indicates that the call has failed.
ErrorMessage String The error message returned when the call fails.
Code String The error code returned when the call fails. For more information about error codes, see Error codes.
Data Data The data returned when the call is successful. For more information, see the following table Data.
Table 2. Data
Parameter Type Description
Result String The result of a synchronous call.
MessageId String The ID of the message which IoT Platform sends to the device.

Examples

Request example

https://iot.cn-shanghai.aliyuncs.com/?Action=InvokeThingService
&ProductKey=al*********
&DeviceName=device1
&Identifier=service
&Args=%7B%22param1%22%3A1%7D
&Public Request Parameters

Response example

  • JSON format

    {
      "RequestId":"57b144cf-09fc-4916-a272-a62902d5b207",
      "Success": true,
      "Data":{"
    	 "Result": "...."
    	 "MessageId": "abcabc123"
      }
    }
  • XML format

    <? xml version='1.0' encoding='utf-8'? >
    <InvokeThingServiceResponse>
        <RequestId>57b144cf-09fc-4916-a272-a62902d5b207</RequestId>
        <Success>true</Success>
    	<Data>
    	     <Result>... </Result>
                 <MessageId>abcabc123</MessageId>
    	</Data>
    </InvokeThingServiceResponse>