Quantcast
Viewing all articles
Browse latest Browse all 6412

OData Link Write Operations

Hi all,

 

Section 7.1.6.9, Custom Exits for OData Write Requests, of the HANA Developer Guide describes how SQLScript procedures can be registered for non-trivial write requests towards an OData service. Besides Entity Write Operations the documentation also describes the possibility of Link Write Operations. I want to apply the latter type of operations in order to create new sub-items of an items EntitySet. For this my service definition looks like this:

 

service namespace "namespace" {
 "namespace::v_complete_item" as "Items" keys ("DB_ID") navigates ("Item_SubItems" as "SubItems" from principal);                            
 association "Item_SubItems" principal "Items" ("DB_ID") multiplicity "1"  dependent "Items" ("DB_ID") multiplicity "*"  over "namespace::t_item_goes_into" principal ("FROM_ITEM_ID") dependent ("TO_ITEM_ID")  create using "namespace::p_item_create";
}

 

In line 7 I reference the procedure "namespace::p_item_create" which shall be called for Link Write Operations. For completeness, here is the procedure:

 

PROCEDURE "_SYS_BIC"."namespace::p_item_create" (
 IN it_principal_item NAMESPACE."namespace::ts_complete_item",
 IN it_dependent_items NAMESPACE."namespace::ts_complete_item",
 OUT ot_error NAMESPACE."namespace::ts_odata_error"
 )
 LANGUAGE SQLSCRIPT
 SQL SECURITY INVOKER 
 DEFAULT SCHEMA NAMESPACE
 AS
BEGIN
 ot_error = select 400 as http_status_code, 'invalid ID' as error_message, 'value must be >= 1000' as detail from dummy;     
END;

 

For now, the procedure does not do anything. It just provides the necessary parameters for a Link Write Operation (in accordance to the documentation) and produces an error message, so that I can see whether the procedure was called or not. There is no problem during the activation of this code.

 

I tried to trigger the execution of "namespace::p_item_create" by a POST request on the Navigation Property, which uses the association:

 

POST http://<system>:8000/<path>/service.xsodata/Items(1)/SubItems

 

However, every time I try this I get the following error message from the service:

 

<?xml version="1.0" encoding="utf-8" standalone="yes"?>  <error       xmlns="http://schemas.microsoft.com/ado/2007/08/dataservices/metadata">      <code/>      <message xml:lang="en-US">The URI is not valid for POST operation. The URI must point to an entity set for POST operations.</message>  </error>  

 

Is there something wrong with the request? Is it not possible to trigger the Link Write Operation by using the Navigation Property? If yes, how can the operation be triggered by a client request? Which resource of the service has to be used?

 

I hope you can help me with that. Unfortunately, the documentation does not provide any details about that.

 

Thanks a million!

 

Best regards,

René

 

PS: I've already posted a similar question as response to an already solved question, but got no response so far. That's why I wanted to make my question a little bit more prominent and provide additional information.


Viewing all articles
Browse latest Browse all 6412

Trending Articles