You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@olingo.apache.org by Buddhika Ratnayake <bu...@gmail.com> on 2022/03/30 01:03:35 UTC

Re: odata.id in response when metadata=minimal

Hi All,

I have come across the same problem as Suneth Mendis.

When using Apache Olingo library although we are sending
metadata=minimal with content type header of the request, @odata.id is
included in the response.

 My understanding was also that @odata.id should not be added to the
response when metadata=minimal

Does anyone know why this was implemented in this manner?


Thank you and Best Regards,

Buddhika



On Mon, 28 Feb 2022 at 07:13, Suneth Mendis <su...@ifs.com> wrote:

> Hi,
>
>
>
> According to OData specification, The id control information (odata.id)
> MUST appear in responses if metadata=full is requested, or
> if metadata=minimal is requested and any of a non-transient entity's key
> fields are omitted from the response *or* the entity-id is not identical
> to the canonical URL of the entity after  IRI-to-URI conversion/ relative
> resolution/ percent-encoding normalization.
>
>
> https://docs.oasis-open.org/odata/odata-json-format/v4.01/odata-json-format-v4.01.html#_Toc38457743
>
>
>
> But when using Apache Olingo library although we are sending
> metadata=minimal with content type header of the request, @odata.id is
> included in the response.
>
>
>
> For example, the request “
> http://localhost:8080/main/projection/SubContractHandling.svc/SubContracts?$top=1&$select=SubConName
> ” with metadata=minimal  is getting a response as follows.
>
> *{*
>
> *"@odata.context":
> http://localhost:8080/main/projection/SubContractHandling.svc/$metadata#SubContracts(SubConNo,SubConName)
> <http://localhost:8080/main/projection/SubContractHandling.svc/$metadata#SubContracts(SubConNo,SubConName)>,*
>
> *"value": [*
>
> *{*
>
> *"@odata.etag":
> "W/\"Vy8iQUFBVVIzQUNPQUFBTCt2QUFBOjIwMjIwMjIzMTYzMTA0Ig==\",*
>
> *"@odata.id <http://odata.id>:
> http://localhost:8080/main/projection/SubContractHandling.svc/SubContracts(SubConNo='C100000025')
> <http://localhost:8080/main/projection/SubContractHandling.svc/SubContracts(SubConNo='C100000025')>,*
>
> *"SubConNo": "C100000025",*
>
> *"SubConName": "SOW Test"*
>
> *}*
>
> *]*
>
> *}*
>
>
>
> When checking ODataJsonSerializer.java in Olingo library, it is appending
> odata.id to the response with following condition.
>
>
>
> if ((!isODataMetadataNone && !areKeyPredicateNamesSelected(select,
> resolvedType)) || isODataMetadataFull)
>
>
>
> Is there any reason for not checking metadata=minimal here ? @odata.id
> should not be added to the response when metadata=minimal too, isn’t it ?
>
>
>
> Thanks and Best Regards,
>
> /Suneth Mendis
>
>
> ------------------------------
> Confidentiality notice and disclaimer
> This e-mail is private and may contain confidential information. You must
> not use, disclose, or retain any of its content if you have received it in
> error: please notify its sender and then delete it. Any views or opinions
> expressed in this e-mail are strictly those of its author. We do not accept
> liability for the consequences of any data corruption, interception,
> tampering, or virus.
>

Re: odata.id in response when metadata=minimal

Posted by Alain <al...@gmail.com>.
I believe that this might not be optimal, but reading 3.1.1: "*metadata=minimal
format parameter indicates that the service SHOULD remove computable
control information from the payload wherever possible. The response
payload MUST contain at least the following control information
<https://docs.oasis-open.org/odata/odata-json-format/v4.01/odata-json-format-v4.01.html#sec_ControlInformation>*,
we see what MUST at least be included, but it doesn't precludes the
inclusion of other control information, which seems in line with many parts
of the specification AFAIK.

Alain

On Tue, Mar 29, 2022 at 9:03 PM Buddhika Ratnayake <bu...@gmail.com>
wrote:

> Hi All,
>
> I have come across the same problem as Suneth Mendis.
>
> When using Apache Olingo library although we are sending
> metadata=minimal with content type header of the request, @odata.id is
> included in the response.
>
>  My understanding was also that @odata.id should not be added to the
> response when metadata=minimal
>
> Does anyone know why this was implemented in this manner?
>
>
> Thank you and Best Regards,
>
> Buddhika
>
>
>
> On Mon, 28 Feb 2022 at 07:13, Suneth Mendis <su...@ifs.com> wrote:
>
>> Hi,
>>
>>
>>
>> According to OData specification, The id control information (odata.id)
>> MUST appear in responses if metadata=full is requested, or
>> if metadata=minimal is requested and any of a non-transient entity's key
>> fields are omitted from the response *or* the entity-id is not identical
>> to the canonical URL of the entity after  IRI-to-URI conversion/ relative
>> resolution/ percent-encoding normalization.
>>
>>
>> https://docs.oasis-open.org/odata/odata-json-format/v4.01/odata-json-format-v4.01.html#_Toc38457743
>>
>>
>>
>> But when using Apache Olingo library although we are sending
>> metadata=minimal with content type header of the request, @odata.id is
>> included in the response.
>>
>>
>>
>> For example, the request “
>> http://localhost:8080/main/projection/SubContractHandling.svc/SubContracts?$top=1&$select=SubConName
>> ” with metadata=minimal  is getting a response as follows.
>>
>> *{*
>>
>> *"@odata.context":
>> http://localhost:8080/main/projection/SubContractHandling.svc/$metadata#SubContracts(SubConNo,SubConName)
>> <http://localhost:8080/main/projection/SubContractHandling.svc/$metadata#SubContracts(SubConNo,SubConName)>,*
>>
>> *"value": [*
>>
>> *{*
>>
>> *"@odata.etag":
>> "W/\"Vy8iQUFBVVIzQUNPQUFBTCt2QUFBOjIwMjIwMjIzMTYzMTA0Ig==\",*
>>
>> *"@odata.id <http://odata.id>:
>> http://localhost:8080/main/projection/SubContractHandling.svc/SubContracts(SubConNo='C100000025')
>> <http://localhost:8080/main/projection/SubContractHandling.svc/SubContracts(SubConNo='C100000025')>,*
>>
>> *"SubConNo": "C100000025",*
>>
>> *"SubConName": "SOW Test"*
>>
>> *}*
>>
>> *]*
>>
>> *}*
>>
>>
>>
>> When checking ODataJsonSerializer.java in Olingo library, it is appending
>> odata.id to the response with following condition.
>>
>>
>>
>> if ((!isODataMetadataNone && !areKeyPredicateNamesSelected(select,
>> resolvedType)) || isODataMetadataFull)
>>
>>
>>
>> Is there any reason for not checking metadata=minimal here ? @odata.id
>> should not be added to the response when metadata=minimal too, isn’t it ?
>>
>>
>>
>> Thanks and Best Regards,
>>
>> /Suneth Mendis
>>
>>
>> ------------------------------
>> Confidentiality notice and disclaimer
>> This e-mail is private and may contain confidential information. You must
>> not use, disclose, or retain any of its content if you have received it in
>> error: please notify its sender and then delete it. Any views or opinions
>> expressed in this e-mail are strictly those of its author. We do not accept
>> liability for the consequences of any data corruption, interception,
>> tampering, or virus.
>>
>