private static void getDeviceShadow(IoTDAClient client) { ShowDeviceShadowRequest req = new ShowDeviceShadowRequest { DeviceId = "5e25d39a3b7c24fa3638804b_nb_0403_1" }; try { var resp = client.ShowDeviceShadow(req); Console.WriteLine(resp.HttpStatusCode); Console.WriteLine(resp.DeviceId); foreach (var DeviceShadowData in resp.Shadow) { Console.WriteLine(JsonConvert.SerializeObject(DeviceShadowData)); } } 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); } }
/// <summary> /// 查询设备影子数据 /// </summary> public async Task <ShowDeviceShadowResponse> ShowDeviceShadowAsync(ShowDeviceShadowRequest showDeviceShadowRequest) { Dictionary <string, string> urlParam = new Dictionary <string, string>(); urlParam.Add("device_id", showDeviceShadowRequest.DeviceId.ToString()); string urlPath = HttpUtils.AddUrlPath("/v5/iot/{project_id}/devices/{device_id}/shadow", urlParam); SdkRequest request = HttpUtils.InitSdkRequest(urlPath, showDeviceShadowRequest); HttpResponseMessage response = await DoHttpRequestAsync("GET", request); return(JsonUtils.DeSerialize <ShowDeviceShadowResponse>(response)); }