Quantcast
Channel: SCN : All Content - SAP Gateway
Viewing all articles
Browse latest Browse all 2823

Creating (POST) an entity via a navigation property?

$
0
0

Hi All,

 

Let's say we have a model that has an Employees entityset, and for a given employee, you can navigate to a CurrentCarParkingSpot entity (it's an example not reality).

 

e.g. Employees('00123456')/CurrentCarParkingSpot would pull up the current CarParkingSpot against the Employee.


Now if the employee didn't have a CarParkingSpot, and I want to create a new CarParkingSpot for this employee, you would think I could POST a standard CarParkingSpot payload to Employees('00123456')/CurrentCarParkingSpot and it should create a new CarParkingSpot against employee (assuming I get the employee key in the GW code). However, when I try this, the framework doesn't even call my code, and it's almost like Gateway does not support creation via a navigation property. PUT works, just not POST.

 

Note - If I post the same payload directly to /CarParkingSpots, it works fine.

 

e.g. The payload looks like:

<?xml version="1.0" encoding="utf-8"?><entry xml:base="http://server.local/sap/opu/odata/sap/ZEXAMPLE/" xmlns="http://www.w3.org/2005/Atom" xmlns:m="http://schemas.microsoft.com/ado/2007/08/dataservices/metadata" xmlns:d="http://schemas.microsoft.com/ado/2007/08/dataservices">  <id>http://server.local/sap/opu/odata/sap/ZEXAMPLE/CarParkingSpot</id>  <title type="text">CarParkingSpot</title>  <category term="ZEXAMPLE.CarParkingSpot" scheme="http://schemas.microsoft.com/ado/2007/08/dataservices/scheme"/>  <content type="application/xml">   <m:properties>   </m:properties>  </content></entry>

So the key question: Is creation (POST) via Navigation Properties supported in GW, and if it is, do you need to alter the payload at all (note - I've tried changing the id and text above to align with navigation property)?

 

FYI - I've been testing via Gateway Client, and getting successful creation by using "Use as request" from an existing specific Employees('another id')/CurrentCarParkingSpot and removing all id's in the POST payload.

 

Thanks,

Matt


Viewing all articles
Browse latest Browse all 2823

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>