コード例 #1
0
        private static void createCommand(IoTDAClient client)
        {
            CreateCommandRequest req = new CreateCommandRequest
            {
                InstanceId = "1a7ffc5c-d89c-44dd-8265-b1653d951ce0",
                DeviceId   = "5eeb1fefbc61700402bc35f9_1211211",
                Body       = new DeviceCommandRequest()
                {
                    ServiceId   = "b1224afb-e9f0-4916-8220-b6bab568e888",
                    CommandName = "ON_OFF",
                    Paras       = JObject.Parse("{\"value\":\"ON\"}")
                }
            };

            try
            {
                var resp = client.CreateCommand(req);
                Console.WriteLine(resp);
            }
            catch (RequestTimeoutException requestTimeoutException)
            {
                Console.WriteLine(requestTimeoutException.ErrorMessage);
            }
            catch (ServiceResponseException clientRequestException)
            {
                Console.WriteLine(clientRequestException.HttpStatusCode);
                Console.WriteLine(clientRequestException.ErrorCode);
                Console.WriteLine(clientRequestException.ErrorMsg);
            }
            catch (ConnectionException connectionException)
            {
                Console.WriteLine(connectionException.ErrorMessage);
            }
        }