Stephan Klevenz created OLINGO-251:
--------------------------------------

             Summary: Handling insert (OData POST of entity) with reverenced to 
an existing entity
                 Key: OLINGO-251
                 URL: https://issues.apache.org/jira/browse/OLINGO-251
             Project: Olingo
          Issue Type: Bug
          Components: odata2-core
            Reporter: Stephan Klevenz
         Attachments: entity-writer-can-serialize-additional-links.patch

Use case: I want to post a new Category entity by referring to an existing 
product.

1. POST/create call to 
http://services.odata.org/(S(egpbfjhhvili4slwaq1p2lvt))/V2/OData/OData.svc/Categories
With the following payload in the rest client
ATOM Payload for POST:

<entry xmlns:d="http://schemas.microsoft.com/ado/2007/08/dataservices"; 
xmlns:m="http://schemas.microsoft.com/ado/2007/08/dataservices/metadata"; 
xmlns="http://www.w3.org/2005/Atom"; 
xml:base="http://services.odata.org/(S(lebb5euydx3m3xt5r2rqmou4))/V2/OData/OData.svc/">
<id>http://services.odata.org/(S(lebb5euydx3m3xt5r2rqmou4))/V2/OData/OData.svc/Categories(1)</id>
<title type="text">Beverages</title>
<updated>2014-03-19T10:31:49Z</updated>
<author>
<name />
</author>
<link rel="edit" title="Category" href="Categories(1)" />
<link 
rel="http://schemas.microsoft.com/ado/2007/08/dataservices/related/Products"; 
type="application/atom+xml;type=feed" title="Products" href="Products(0)" />
<category term="ODataDemo.Category" 
scheme="http://schemas.microsoft.com/ado/2007/08/dataservices/scheme"; />
<content type="application/xml">
<m:properties>
<d:ID m:type="Edm.Int32">999</d:ID>
<d:Name>Foodie</d:Name>
</m:properties>
</content>
</entry>

Point to be noted here is the link reference to Products(0).

2. I get http response as 201.
3. Now, GET/READ call to 
http://services.odata.org/(S(egpbfjhhvili4slwaq1p2lvt))/V2/OData/OData.svc/Categories(999)?$expand=Products
 gives response with Products (0) as inline property (ODataResponse.xml can be 
checked).

I would like to know how to handle this when I try to achieve it through olingo 
library. What other information should be given to EntityProvider.writeEntry 
API.

The signature of this API is
ODataResponse org.apache.olingo.odata2.api.ep.EntityProvider.writeEntry(String 
contentType, EdmEntitySet entitySet, Map<String, Object> data, 
EntityProviderWriteProperties properties) throws EntityProviderException
The information about the referenced entity [Products(0) in this case] cannot 
be part of data (map). Could you please help us understanding how to handle 
this.





--
This message was sent by Atlassian JIRA
(v6.2#6252)

Reply via email to