MicrosoftDocs / azure-docs

Open source documentation of Microsoft Azure
https://docs.microsoft.com/azure
Creative Commons Attribution 4.0 International
10.23k stars 21.39k forks source link

Value and Property cannot be null when we use the method "RemoveDesiredProperties" to Delete the property. #121502

Open RichChen0602 opened 5 months ago

RichChen0602 commented 5 months ago

Hi Team,

Wish you all well!

We tried to use the method below to remove the properties, but we cannot pass the null value. May have your assistance on the symptom? Any input will be appreciated! Thank you so much and have a nice day.

https://github.com/Azure/azure-iot-service-sdk-java/blob/main/service/iot-service-samples/device-twin-sample/src/main/java/samples/com/microsoft/azure/sdk/iot/DeviceTwinSample.java

Method: private static void removeDesiredProperties(TwinClient twinClient) throws IOException, IotHubException { Twin newTwins = new Twin(deviceId); newTwins.getDesiredProperties().put("hum", null);

     System.out.println("Updating Device twin (remove hum)");
     twinClient.patch(newTwins);

     System.out.println("Getting the updated Device twin");
     Twin updatedTwin = twinClient.get(deviceId);
     System.out.println(updatedTwin);
Naveenommi-MSFT commented 5 months ago

@RichChen0602 Thanks for your feedback! We will investigate and update as appropriate.

Naveenommi-MSFT commented 5 months ago

@RichChen0602 Thank you for bringing this to our attention. I've delegated this to content author @ethanann-ms, who will review it and offer their insightful opinions.