Skip to Content
2
Mar 31, 2020 at 12:56 PM

Error ASSERT_REFERENCE_INTEGRITY on CAP Compositions

404 Views

Hello everybody!

I am creating two entities following CAP tutorial, one of them is composed by the other, so the schema would be this:

entity Proposal {
	key ID: UUID;
	budgets: Composition of many Budgets on budgets.proposal = $self;
}

entity Budget {
	key proposal: Association to Proposal;
	key ID: String(2);
}

If I exposed my service and I try to make a POST request with this body:

{
	"desc": "First example",
	"budget": [
		{
			ID: "AA"
		},
		{
			ID: "BB"
		}
	]
}

First call returns a 201 code, so it is ok, but if I try a second request with the same data, it returns the following error:

{ "error": { "code": "ASSERT_REFERENCE_INTEGRITY", "message": "Reference integrity is violated for association 'proposal'", "target": "api.Proposal" } }

I don´t understand this error since I am using a different key for Proposal so it could create another two registries for Budget.

Thank you for the response.