You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Edit: Added a comment explaining the reason of this behavior and changed the issue title.
Microsoft Graph core returns an object with all properties set to null, if the response body contains a nested structure.
Expected behavior
com.microsoft.graph.core.requests.ResponseBodyHandler#handleResponse should parse nested response objects. And maybe throw an error if a response can not be parsed.
Actual behavior
com.microsoft.graph.core.requests.ResponseBodyHandler#handleResponse returns a object with all properties set to null.
Steps to reproduce the behavior
Execute the following request using the Graph API: POST https://graph.microsoft.com/v1.0/$batch
Body is GET users?$filter=identities/any(c:c/issuerAssignedId eq '<the issuer Assigned id>' and c/issuer eq 'contoso.com')&$select=id,displayName,email,UserPrincipalName,identities,accountEnabled
The image shows the structure of parseNode in com.microsoft.graph.core.requests.ResponseBodyHandler#handleResponse for a Request that CAN NOT be parsed:
The image shows the structure of parseNode in com.microsoft.graph.core.requests.ResponseBodyHandler#handleResponse for a request that CAN be parsed:
Remarks
I verified this by unnesting the structure and re-parsing the response:
An intermediate fix (not yet tested) could be to provide your own implementation of ResponseBodyHandler when invoking com.microsoft.graph.core.content.BatchResponseContentCollection#getResponseById(java.lang.String, com.microsoft.kiota.ResponseHandler)
The text was updated successfully, but these errors were encountered:
I apologize for the confusion earlier; the issue actually originated from my misunderstanding. The query users?$filter=identities returns a UserCollectionResponse. Consequently, I should be utilizing UserCollectionResponse::createFromDiscriminatorValue instead of User::createFromDiscriminatorValue.
This suggests that an enhancement could be to introduce error handling for cases where an inappropriate discriminator value is provided, which might not be parseable under the current method. This could prevent similar misunderstandings in the future. Thank you for your patience.
andnorxor
changed the title
Batch responses not parsed correctly when they contain a nested body structure
Batch response: Improved error handling when "UserCollectionResponse" is returned but discrimiator is set to "User"
Apr 28, 2024
Graph Core Version: 3.1.9
Kiota Version: 1.1.7
Affected Method: com.microsoft.graph.core.requests.ResponseBodyHandler#handleResponse
Edit: Added a comment explaining the reason of this behavior and changed the issue title.
Microsoft Graph core returns an object with all properties set to null, if the response body contains a nested structure.
Expected behavior
com.microsoft.graph.core.requests.ResponseBodyHandler#handleResponse
should parse nested response objects. And maybe throw an error if a response can not be parsed.Actual behavior
com.microsoft.graph.core.requests.ResponseBodyHandler#handleResponse
returns a object with all properties set tonull
.Steps to reproduce the behavior
Execute the following request using the Graph API:
POST https://graph.microsoft.com/v1.0/$batch
Body is
GET users?$filter=identities/any(c:c/issuerAssignedId eq '<the issuer Assigned id>' and c/issuer eq 'contoso.com')&$select=id,displayName,email,UserPrincipalName,identities,accountEnabled
Response: shortended just to show the structure. Note the nested structure in the body which causes the erroneous behavior.
The image shows the structure of
![image](https://private-user-images.githubusercontent.com/11016573/325794373-7c42cf89-1fdf-48fc-8521-34396d7666fd.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3Mzk1OTYyMTYsIm5iZiI6MTczOTU5NTkxNiwicGF0aCI6Ii8xMTAxNjU3My8zMjU3OTQzNzMtN2M0MmNmODktMWZkZi00OGZjLTg1MjEtMzQzOTZkNzY2NmZkLnBuZz9YLUFtei1BbGdvcml0aG09QVdTNC1ITUFDLVNIQTI1NiZYLUFtei1DcmVkZW50aWFsPUFLSUFWQ09EWUxTQTUzUFFLNFpBJTJGMjAyNTAyMTUlMkZ1cy1lYXN0LTElMkZzMyUyRmF3czRfcmVxdWVzdCZYLUFtei1EYXRlPTIwMjUwMjE1VDA1MDUxNlomWC1BbXotRXhwaXJlcz0zMDAmWC1BbXotU2lnbmF0dXJlPTIwNTgwM2RiNzlhMjRmMDdkOTkwNDljOTE5MzFmNDRjOWQ4OGViZWRiYTJmNmMyNDIwMDAyMmEzNGQwMmY0ODMmWC1BbXotU2lnbmVkSGVhZGVycz1ob3N0In0.viXsYwwuiXq0Qg9SipOcHE1uF9QVbtIh-hZUawoGWnI)
parseNode
incom.microsoft.graph.core.requests.ResponseBodyHandler#handleResponse
for a Request that CAN NOT be parsed:The image shows the structure of
![image](https://private-user-images.githubusercontent.com/11016573/325793494-1afbaed3-a20f-4f92-8aec-0327f3970388.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3Mzk1OTYyMTYsIm5iZiI6MTczOTU5NTkxNiwicGF0aCI6Ii8xMTAxNjU3My8zMjU3OTM0OTQtMWFmYmFlZDMtYTIwZi00ZjkyLThhZWMtMDMyN2YzOTcwMzg4LnBuZz9YLUFtei1BbGdvcml0aG09QVdTNC1ITUFDLVNIQTI1NiZYLUFtei1DcmVkZW50aWFsPUFLSUFWQ09EWUxTQTUzUFFLNFpBJTJGMjAyNTAyMTUlMkZ1cy1lYXN0LTElMkZzMyUyRmF3czRfcmVxdWVzdCZYLUFtei1EYXRlPTIwMjUwMjE1VDA1MDUxNlomWC1BbXotRXhwaXJlcz0zMDAmWC1BbXotU2lnbmF0dXJlPTUzNGQ2NjVlM2I5ZjU3NjAwZjk4MTkzZDQwZWJjODFkNDVlNWQzYzJmM2IyNTI3NmNhMzFiZmE0N2JmNDEwMTkmWC1BbXotU2lnbmVkSGVhZGVycz1ob3N0In0.JaecI35eHZY2UI7b3JR0eydz1Py72eWuQ8RDIcHYuag)
parseNode
incom.microsoft.graph.core.requests.ResponseBodyHandler#handleResponse
for a request that CAN be parsed:Remarks
I verified this by unnesting the structure and re-parsing the response:
An intermediate fix (not yet tested) could be to provide your own implementation of
ResponseBodyHandler
when invokingcom.microsoft.graph.core.content.BatchResponseContentCollection#getResponseById(java.lang.String, com.microsoft.kiota.ResponseHandler)
The text was updated successfully, but these errors were encountered: