Elvis 6 REST API - create relation
http://yourserver.com/services/createRelation ?relationType=<relation type> &target1Id=<asset id> &target2Id=<another asset id> &metadata=<JSON encoded metadata> &<Elvis metadata field name>=<value>
What does it do?
This call creates a relation of a certain type between two assets in Elvis. For example, to add an asset to a collection.
Note: When a relation between two assets exists — even of a different type — it is not possible to create a new one.
POST requests only
This REST API only accepts POST requests, not GET requests. Also, the POST request needs to include a cross-site request forgery (csrf) token.
The csrf token is a unique code which, by including it in the request, also makes the POST request unique and therefore much more secure.
The csrf token is obtained by first logging in to Elvis Server through a POST request. The response that is received will include the csrf token which can then be used in subsequent POST requests as a http header:
For more information including examples, see Elvis 6 REST API - Performing a POST request with a csrf token.
The type of relation to create.
The id of the asset on one side of the relation.
If the relation type is a directional relation, this must be the id of the 'parent'-side.
The id of the asset on the other side of the relation.
If the relation type is a directional relation, this must be the id of the 'child'-side.
A JSON encoded object with properties that match Elvis relation metadata field names. This metadata will be set on the relation in Elvis.
Optional. You can also use parameters matching Elvis relation field names.
Any parameter matching an Elvis relation metadata field name will be used as relation metadata. This metadata will be set on the relation in Elvis.
Optional. You also use the 'metadata' parameter.
The operation returns an empty 200 OK status.
If the operation fails, an error page with a 500 error status will be returned.
http://demo.elvisdam.com/services/createRelation ?relationType=contains &target1Id=ATT8CDno4QCB59QHmjwnfS &target2Id=Cbg9-_ukKEZARORmuaCsn3
Creates a relation between 2 assets. In this case between:
- People.collection (ATT8CDno4QCB59QHmjwnfS)
- Kiting.jpg (Cbg9-_ukKEZARORmuaCsn3)
You can also use the 'reverse' relation type, but then you also have to reverse the IDs used in target 1 and target 2:
http://demo.elvisdam.com/services/createRelation ?relationType=contained-by &target1Id=Cbg9-_ukKEZARORmuaCsn3 &target2Id=ATT8CDno4QCB59QHmjwnfS
- 27 July 2017: Added section 'Post requests only'.