private static void freezeDevice(IoTDAClient client) { FreezeDeviceRequest req = new FreezeDeviceRequest { DeviceId = "5e25d39a3b7c24fa3638804b_1211211", InstanceId = "1a7ffc5c-d89c-44dd-8265-b1653d951ce0" }; try { var resp = client.FreezeDevice(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); } }
/// <summary> /// 冻结设备 /// </summary> public FreezeDeviceResponse FreezeDevice(FreezeDeviceRequest freezeDeviceRequest) { Dictionary <string, string> urlParam = new Dictionary <string, string>(); urlParam.Add("device_id", freezeDeviceRequest.DeviceId.ToString()); string urlPath = HttpUtils.AddUrlPath("/v5/iot/{project_id}/devices/{device_id}/freeze", urlParam); SdkRequest request = HttpUtils.InitSdkRequest(urlPath, freezeDeviceRequest); HttpResponseMessage response = DoHttpRequestSync("POST", request); FreezeDeviceResponse freezeDeviceResponse = JsonUtils.DeSerializeNull <FreezeDeviceResponse>(response); return(freezeDeviceResponse); }