You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@olingo.apache.org by "Patel, Yesha" <ye...@sap.com> on 2022/11/18 16:46:27 UTC

OData V4 Deep insert

Hi,
I am trying to find documentation on how to create entity with deep insert.  Below link shows how to create a service to handle the requests, but there is no example for clients on how to write deep insert payload and what api to use.

https://olingo.apache.org/doc/odata4/tutorials/deep_insert/tutorial_deep_insert.html


For example:
Our current implementation:

 Payload :
{
"tname" : "s2",
"tdescription" : "",
test@odata.bind<ma...@odata.bind> : [ https://<service>/testentity(seq='1',sName='s2test')<https://%3cservice%3e/testentity(seq='1',sName='s2test')> ]
}
Expected Payload:

{
"tname": "s2",
"tdescription": "",
"test": [
{
 "sName": "s2test",
"seq": "1"
},
{
"ttName": "s3",
 "seq": "s3test"
}
]
}


Basically, instead doing odata.bind annotation, it needs to create the nested structure for navigation property.

I am using below

Map<String, Map<String, Object>> entityLinkMap = getNaviPropertyValueMap(entitySetName, columns, values);


            for (String naviPropName : entityLinkMap.keySet()) {
                  EdmNavigationProperty naviProp = entityType.getNavigationProperty(naviPropName);
                  String naviSetName = edmEntitySet.getRelatedBindingTarget(naviPropName).getName();
//Here it will create the link for odata.bind
                  ClientLink clientLink = createClientLink(client, serviceUrl, naviSetName, naviProp,
                              entityLinkMap.get(naviPropName));
                  clientEntity.getNavigationLinks().add(clientLink);
            }

What api will be useful here?

Thanks,
Yesha