GET/POST 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.
Parameters
relationType |
The type of relation to create. Required. |
target1Id |
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. Required. |
target2Id |
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. Required. |
metadata |
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. |
Return value
The operation returns an empty 200 OK status.
If the operation fails, an error page with a 500 error status will be returned.
Examples
createRelation 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:
createRelation http://demo.elvisdam.com/services/createRelation ?relationType=contained-by &target1Id=Cbg9-_ukKEZARORmuaCsn3 &target2Id=ATT8CDno4QCB59QHmjwnfS |
Document history
- 27 December 2016: Added note stating that when a relation between two assets exists — even of a different type — it is not possible to create a new one.
Comments
0 comments
Please sign in to leave a comment.