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
OData .NET Client fails to parse responses where @odata.context relative path starts with $metadata#, which some services respond with. Eg. $metadata#Projects. Mocking a response with just Projects works fine.
Assemblies affected
OData .Net lib 7.10.0 in .NET 6
Reproduce steps
Try parse a Json response where @odata.context consists of a relative path starting with $metadata#
Expected result
The Json should be parsed into objects accordingly, just like if the @odata.context would be just eg Projects
Actual result
With multiple entity retrieval it throws
System.ArgumentOutOfRangeException: Length cannot be less than zero. (Parameter 'length')
at System.String.Substring(Int32 startIndex, Int32 length)
at Microsoft.OData.TypeUtils.ParseQualifiedTypeName(String qualifiedTypeName, String& namespaceName, String& typeName, Boolean& isCollection)
...
and with single entity retrieval it throws System.InvalidOperationException: The response payload is a not a valid response payload. Please make sure that the top level element is a valid Atom or JSON element or belongs to '[http://docs.oasis-open.org/odata/ns/data]()' namespace..
Additional detail
I saw issue #2132, which probably fixed relative paths without $metada#. This might be related.
The text was updated successfully, but these errors were encountered:
I can't give you access to repo or endpoint, but here is a .NET project and mock json-server that demonstrates the issue we ran into.
It has 4 endpoints in swagger UI, where the first two result in the above mentioned excepitons, and the last two works as expected. Payloads are served from and found in serveOdata/OData.json
OData .NET Client fails to parse responses where
@odata.context
relative path starts with$metadata#
, which some services respond with. Eg.$metadata#Projects
. Mocking a response with justProjects
works fine.Assemblies affected
OData .Net lib 7.10.0 in .NET 6
Reproduce steps
Try parse a Json response where
@odata.context
consists of a relative path starting with$metadata#
Expected result
The Json should be parsed into objects accordingly, just like if the
@odata.context
would be just egProjects
Actual result
With multiple entity retrieval it throws
and with single entity retrieval it throws
System.InvalidOperationException: The response payload is a not a valid response payload. Please make sure that the top level element is a valid Atom or JSON element or belongs to '[http://docs.oasis-open.org/odata/ns/data]()' namespace.
.Additional detail
I saw issue #2132, which probably fixed relative paths without
$metada#
. This might be related.The text was updated successfully, but these errors were encountered: