Skip to Content
0

Deep/multiple insert on xsodata

Nov 17, 2017 at 01:02 PM

61

avatar image
Former Member

I was following the answer from this https://archive.sap.com/discussions/thread/3604817 thread which allows to create a batch request manually to create associated entries..

This is how my request payload looks like :

--batch
Content-Type:multipart/mixed;boundary=changeset
Content-Transfer-Encoding:binary

--changeset
Content-Type:application/http
Content-Transfer-Encoding:binary
Content-ID: 1

POST customer HTTP/1.1
Content-Type: application/json
Content-Length:18

{"customerId":"7"}
--changeset
Content-Type:application/http
Content-Transfer-Encoding:binary
Content-ID: 2

POST OrderEntity HTTP/1.1
Content-Type:application/json
Content-Length:15

{"orderId":"1"}
--changeset
Content-Type:application/http
Content-Transfer-Encoding:binary

PUT $1/$links/toOrder HTTP/1.1
Content-Type:application/json
Content-Length:12

{"uri":"$2"}
--changeset--

--batch--

And the metadata of my xsodata service:

<edmx:Edmx xmlns:edmx="http://schemas.microsoft.com/ado/2007/06/edmx" Version="1.0">
<edmx:DataServices xmlns:m="http://schemas.microsoft.com/ado/2007/08/dataservices/metadata" m:DataServiceVersion="2.0">
<Schema xmlns:d="http://schemas.microsoft.com/ado/2007/08/dataservices" xmlns:m="http://schemas.microsoft.com/ado/2007/08/dataservices/metadata" xmlns="http://schemas.microsoft.com/ado/2008/09/edm"Namespace="default">
<EntityType Name="customerType">
<Key>
<PropertyRef Name="customerId"/>
</Key>
<Property Name="customerId" Type="Edm.Int64" Nullable="false"/>
<Property Name="orderId.orderId" Type="Edm.Int64"/>
<NavigationProperty Name="toOrder" Relationship="default.toOrderType" FromRole="customerPrincipal" ToRole="OrderEntityDependent"/>
</EntityType>
<EntityType Name="OrderEntityType">
<Key>
<PropertyRef Name="orderId"/>
</Key>
<Property Name="orderId" Type="Edm.Int64" Nullable="false"/>
</EntityType>
<Association Name="toOrderType">
<End Type="default.customerType" Role="customerPrincipal" Multiplicity="1"/>
<End Type="default.OrderEntityType" Role="OrderEntityDependent" Multiplicity="1"/>
</Association>
<EntityContainer Name="v2" m:IsDefaultEntityContainer="true">
<EntitySet Name="customer" EntityType="default.customerType"/>
<EntitySet Name="OrderEntity" EntityType="default.OrderEntityType"/>
<AssociationSet Name="toOrder" Association="default.toOrderType">
<End Role="customerPrincipal" EntitySet="customer"/>
<End Role="OrderEntityDependent" EntitySet="OrderEntity"/>
</AssociationSet>
/EntityContainer>
</Schema>
</edmx:DataServices>
</edmx:Edmx>

But the third part of the batch request is not being executed and I get following error: "Syntax error in resource path at position ."

I am guessing that the $1 and $2 uri are not being replaced correctly. Is there any thing that I need to change or any other way to achieve the association entry from xsodata?

10 |10000 characters needed characters left characters exceeded
* Please Login or Register to Answer, Follow or Comment.

0 Answers