You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@olingo.apache.org by Rudolf,
,
CELUM,
,
ru...@celum.com on 2015/12/09 08:02:22 UTC
@odata.id for each expanded navigation-property entry in .net C#
client
Hello,
We're using Olingo with expand navigation-properties to navigate from an entity called "Node" of the resource "Nodes" to "Subnodes" of the same entity type (like a folder structure). When using .net C# (Visual Studio Community 2015, with the OData Client Generator) as client we generate the necessary code for accessing the OData service.
It seems .net requires an @odata.id for each expanded navigation-property entry, but we've found no way to activate this behavior using oling, beside overriding the ODataJsonSerializer and adapt the writeEntity method from:
if (onlyReference) {
json.writeStringField(Constants.JSON_ID, entity.getId().toASCIIString());
} else {
to:
if (entity.getId() != null) {
json.writeStringField(Constants.JSON_ID, entity.getId().toASCIIString());
}
if (!onlyReference) {
...
}
So, we write @odata.id, no matter if onlyReference is true or false.
Did we miss something here? Is the behavior of the .net client correct?
Thx for your help!
Best,
Rudolf Traunmüller
CELUM GMBH
rudolf.traunmueller@celum.com
Background:
Our call to https://host/odata/Nodes(900)?$expand=children without patch delivers expanded children without @odata.id for the children -> this fails with the .net client
{
"@odata.context": "https://host/odata/$metadata#Nodes/$entity",
"id": 900,
...
"children": [
{
"id": 1400,
...
}
}
Our call using the patched version to https:// host/odata/Nodes(900)?$expand=children delivers expanded children with @odata.id for the children -> this is now deserialized correctly within .net
{
"@odata.context": "https://host/odata/$metadata#Nodes/$entity",
"id": 900,
...
"children": [
{
"@odata.id": "https://host/odata/$metadata#Nodes(id=1400)",
"id": 1400,
...
}
}
RE: @odata.id for each expanded navigation-property entry in .net
C# client
Posted by "Handl, Ralf" <ra...@sap.com>.
Hi,
The @odata.id can be omitted in the typical use cases. It has to be present in certain circumstances described here: http://docs.oasis-open.org/odata/odata-json-format/v4.0/errata02/os/odata-json-format-v4.0-errata02-os-complete.html#_Toc403940621.
Thanks!
--Ralf
From: Rudolf Traunmüller [CELUM] [mailto:rudolf.traunmueller@celum.com]
Sent: Mittwoch, 9. Dezember 2015 08:02
To: user@olingo.apache.org
Subject: @odata.id for each expanded navigation-property entry in .net C# client
Hello,
We're using Olingo with expand navigation-properties to navigate from an entity called "Node" of the resource "Nodes" to "Subnodes" of the same entity type (like a folder structure). When using .net C# (Visual Studio Community 2015, with the OData Client Generator) as client we generate the necessary code for accessing the OData service.
It seems .net requires an @odata.id for each expanded navigation-property entry, but we've found no way to activate this behavior using oling, beside overriding the ODataJsonSerializer and adapt the writeEntity method from:
if (onlyReference) {
json.writeStringField(Constants.JSON_ID, entity.getId().toASCIIString());
} else {
to:
if (entity.getId() != null) {
json.writeStringField(Constants.JSON_ID, entity.getId().toASCIIString());
}
if (!onlyReference) {
...
}
So, we write @odata.id, no matter if onlyReference is true or false.
Did we miss something here? Is the behavior of the .net client correct?
Thx for your help!
Best,
Rudolf Traunmüller
CELUM GMBH
rudolf.traunmueller@celum.com<ma...@celum.com>
Background:
Our call to https://host/odata/Nodes(900)?$expand=children without patch delivers expanded children without @odata.id for the children -> this fails with the .net client
{
"@odata.context": "https://host/odata/$metadata#Nodes/$entity",
"id": 900,
...
"children": [
{
"id": 1400,
...
}
}
Our call using the patched version to https:// host/odata/Nodes(900)?$expand=children delivers expanded children with @odata.id for the children -> this is now deserialized correctly within .net
{
"@odata.context": "https://host/odata/$metadata#Nodes/$entity",
"id": 900,
...
"children": [
{
"@odata.id": "https://host/odata/$metadata#Nodes(id=1400)",
"id": 1400,
...
}
}