SAP-samples/cloud-cap-samples

Issue with Many-to-many association.

Nandanchaturvedi opened this issue · 3 comments

I have created a many-to-many association as described here:
https://cap.cloud.sap/docs/guides/domain-models#managed-many-to-many-associations

However, while creating the entity, as it would be a deep insert, I get the following error:

"message": "Error while deserializing payload. 'contacts' does not exist in type 'DSPPfgService.PfgRequests'."

This is how i tried creating the entity

{
"ID": 1001,
"title": "API Created",
"customer_ID":90002,

        "contacts":[
			{
			"contact_ID" : 2
			},
			{
			"contact_ID" : 1
			}
		]
	}

While I try to make all IDs Guid, I get the following error:

{
"error": {
"code": "400",
"message": "Deep insert with to-many Associations is not allowed"
}
}

This is how the model looks like:

entity PfgRequests : managed, cuid {
contacts : Association to many PfgContacts on contacts.pfgRequest = $self;
}
entity Contacts : cuid {
pfgRequests : Association to many PfgContacts on pfgRequests.contact = $self;
}

entity PfgContacts { //maintains many-many entity
key pfgRequest: Association to PfgRequests;
key contact: Association to Contacts;
}

And I have exposed all three in the service

chgeo commented

Seems to be duplicate of #94