Beispiel #1
0
        private static void showDeviceMessage(IoTDAClient client)
        {
            ShowDeviceMessageRequest req = new ShowDeviceMessageRequest
            {
                InstanceId = "1a7ffc5c-d89c-44dd-8265-b1653d951ce0",
                DeviceId   = "",
                MessageId  = ""
            };

            try
            {
                var resp = client.ShowDeviceMessage(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);
            }
        }
Beispiel #2
0
        /// <summary>
        /// 查询指定消息id的消息
        /// </summary>
        public async Task <ShowDeviceMessageResponse> ShowDeviceMessageAsync(ShowDeviceMessageRequest showDeviceMessageRequest)
        {
            Dictionary <string, string> urlParam = new Dictionary <string, string>();

            urlParam.Add("device_id", showDeviceMessageRequest.DeviceId.ToString());
            urlParam.Add("message_id", showDeviceMessageRequest.MessageId.ToString());
            string              urlPath  = HttpUtils.AddUrlPath("/v5/iot/{project_id}/devices/{device_id}/messages/{message_id}", urlParam);
            SdkRequest          request  = HttpUtils.InitSdkRequest(urlPath, showDeviceMessageRequest);
            HttpResponseMessage response = await DoHttpRequestAsync("GET", request);

            return(JsonUtils.DeSerialize <ShowDeviceMessageResponse>(response));
        }