Java sdk is giving null value in get cell action
When trying to fetch cell values via the Java SDK, we're encountering an unexpected problem: the value returned is null. Strangely, in Postman and Graph Explorer, the values display correctly.
Our goal was to smoothly retrieve the cell value using the Java SDK, but it's not working. Please assist, with the mentioned issue.
Postman screenshot:
Java sdk screenshot:
Kindly assist with the above comment. Thanks!
Pleases assist us. Thanks!
OK I did confirm with @Ndiritu that it should work, given the support in Kiota for microsoft.graph.Json was added recently. So, we need to look into the issue. Also see the question asked here: https://stackoverflow.com/questions/78457958/get-cell-value-using-graph-api-v6-x-is-not-displaying-the-value-in-java-sdk
PR was merged: https://github.com/microsoft/kiota-java/pull/1070
CC @sebastienlevert
Thanks for the response @petrhollayms . Can you please let me know that, is this issue new and if it's new then what is the expected time it would take to fix it. And also if fixed then how to consume the fixed version?
@ashish777gupta the value is not null. The actual value is nested under some abstractions. The challenge is that the API returns JSON for this property & we don't want to tie our generated code to any JSON lib dependency.
To get a JSON string of the actual value which you can parse with your JSON lib of choice
String jsonString = KiotaJsonSerialization.serializeAsString(workbookRange.getValues());
Otherwise the value is nested under a bunch of abstractions
if (workbookRange.getValues() != null) {
UntypedArray untypedValues = (UntypedArray) workbookRange.getValues();
java.util.List<UntypedNode> cellValuesList = (java.util.List<UntypedNode>) untypedValues.getValue();
UntypedArray untypedFirstCellValue = (UntypedArray) cellValuesList.get(0);
java.util.List<UntypedNode> cellValues = (java.util.List<UntypedNode>) untypedFirstCellValue.getValue();
Double cellValue = ((UntypedDouble) cellValues.get(0)).getValue();
}
You can use these as references:
- https://learn.microsoft.com/en-us/openapi/kiota/serialization?tabs=java#serialization-helpers
- https://learn.microsoft.com/en-us/openapi/kiota/serialization?tabs=java#untyped-node
Please let me know if this works.
Thanks for the response @Ndiritu