POST http://yourserver.com/services/createRelation ?relationType=<relation type> &target1Id=<asset id> &target2Id=<another asset id> |
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:
"X-CSRF-TOKEN: <some_csrf_token>"
For more information including examples, see Elvis 6 REST API - Performing a POST request with a csrf token.
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. |
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
- 26 March 2019: Removed references of the 'metadata' parameter.
- 26 March 2019: Removed references of the '*' parameter.
Comment
Do you have corrections or additional information about this article? Leave a comment! Do you have a question about what is described in this article? Please contact Support.
0 comments
Please sign in to leave a comment.