-
Notifications
You must be signed in to change notification settings - Fork 143
Open
Labels
status:waiting-for-triageAn issue that is yet to be reviewed or assignedAn issue that is yet to be reviewed or assignedtype:bugA broken experienceA broken experience
Description
Description
The SDK throws IllegalStateException
while processing batch responses when the body.error
field is explicitly present but set to null
.
The following exception is thrown:
java.lang.IllegalStateException: Not a JSON Object: null
at com.google.gson.JsonElement.getAsJsonObject(JsonElement.java:91)
at com.microsoft.graph.core.content.BatchResponseContent.getResponseFromJsonObject(BatchResponseContent.java:199)
Expected behavior
The SDK should ignore error: null and correctly process value.
How to reproduce
Create a batch request with a countIf operation in Microsoft Graph java SDK.
public void countIf(String driveId, String itemId, String criteria, String range) throws IOException {
// Construct the CountIfPostRequestBody
CountIfPostRequestBody countIfPostRequestBody = new CountIfPostRequestBody();
countIfPostRequestBody.setCriteria(new UntypedString(criteria));
countIfPostRequestBody.setRange(new UntypedObject(Map.of("Address", new UntypedString(range))));
// Call the Graph API
RequestInformation postRequestInformation = graphServiceClient
.drives()
.byDriveId(driveId)
.items()
.byDriveItemId(itemId)
.workbook()
.functions()
.countIf()
.toPostRequestInformation(countIfPostRequestBody);
BatchRequestContent batchRequestContent = new BatchRequestContent(graphServiceClient);
String requestId = batchRequestContent.addBatchRequestStep(postRequestInformation);
BatchResponseContent batchResponseContent =
graphServiceClient.getBatchRequestBuilder().post(batchRequestContent, null);
Response response = batchResponseContent.getResponseById(requestId);
}
Microsoft Graph API returns a valid batch response like this:
{
"responses": [
{
"id": "countIfRequest",
"status": 200,
"body": {
"@odata.context": "https://graph.microsoft.com/v1.0/$metadata#microsoft.graph.workbookFunctionResult",
"error": null,
"value": 174
}
}
]
}
SDK Version
6.39.0
Latest version known to work for scenario above?
No response
Known Workarounds
No response
Debug output
Click to expand log
```</details>
### Configuration
_No response_
### Other information
_No response_
Metadata
Metadata
Assignees
Labels
status:waiting-for-triageAn issue that is yet to be reviewed or assignedAn issue that is yet to be reviewed or assignedtype:bugA broken experienceA broken experience