/// <summary> /// 绑定标签 /// </summary> public TagDeviceResponse TagDevice(TagDeviceRequest tagDeviceRequest) { Dictionary <string, string> urlParam = new Dictionary <string, string>(); string urlPath = HttpUtils.AddUrlPath("/v5/iot/{project_id}/tags/bind-resource", urlParam); SdkRequest request = HttpUtils.InitSdkRequest(urlPath, "application/json", tagDeviceRequest); HttpResponseMessage response = DoHttpRequestSync("POST", request); TagDeviceResponse tagDeviceResponse = JsonUtils.DeSerializeNull <TagDeviceResponse>(response); return(tagDeviceResponse); }
private static void bindTagsToResource(IoTDAClient client) { TagDeviceRequest req = new TagDeviceRequest { Body = new BindTagsDTO() { ResourceId = "5e25d39a3b7c24fa3638804b_nb_0403_1", ResourceType = "device", Tags = new List <TagV5DTO>() { new TagV5DTO() { TagKey = "testTagName", TagValue = "testTagValue" } } } }; try { var resp = client.TagDevice(req); Console.WriteLine(resp.HttpStatusCode); 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); } }