Create or update relations between objects
Relations can be created between objects that already exist in the Alfabet database. If an object does not exist, the relation is not set and the REFSTR of the object or objects that could not be found is returned in an array in a JSON field NotFound in the return value.
A relation between two objects is established via a property of one of the objects that is of the type Reference or ReferenceArray . Although different mechanisms exist for storage of relations for properties of the type Reference and ReferenceArray , these differences are of no importance for the definition of the relation in the service call. This is handled by the Alfabet RESTful API on server side.
If a relation is defined that already exists in the Alfabet database, the following happens:
- If the object class property storing the relation is of the type Reference, the existing reference is overwritten.
- If the object class property storing the relation is of the type ReferenceArray , the new reference is added to the array and existing references persist. If you want a relation of the type ReferenceArray to be substituted, you must delete the old relation with a service request of the endpoint delete and create a new one with this service request.
To create a new relation, the JSON object of the request must contain a Relations field. The value of this field is a JSON list of objects, each object defining one relation between Alfabet objects to be created or updated with the following fields:
Field name | Required Value |
---|---|
FromRef | The value of the REFSTR property of the Alfabet object for that the property establishing the relation is defined.
Use a service call to the endpoint objects to get information about the REFSTR property of existing objects. Click for information about the service call to export object information. |
Property | The value of the Name attribute of the object class property establishing the relation. Click to see a list of the object class properties for which relations can be updated or created. |
ToRef | The value of the REFSTR property of the Alfabet object to which the relation is established.
Use a service call to the endpoint objects to get information about the REFSTR property of existing objects. Click for information about the service call to export object information. |
RESTful Service call:
Service call: https://AlfabetCloud/AlfabetAPIServer/api/v2/update
HTTP method: PUT
Headers:
- Authorization: bearer eyJ0eXAiOiJKVxMiJ9.eyJpc3MiOiJhbGZhYmV0IiwiaWF0IjoiMTU3MzAzMjA0NiIsImV4cCI6IjE1NzMwMzMyNDYiLCJxc2giOm51bGwsInN1YiI6IkFwaSBBdXRoZW50aWNhdGlvbiIsImNvbnRleHQiOnsidXNlciI6eyJVc2VyS2V5IjoiQUxGQUJFRDRUNGNc1R5cGUiOjB9fX0.PJC0EWtlUETbraV7NckVkRTFVm356y6K9JyhFR245hXp-2ApttryATZ_dAL0bi_GZpeJx7iqr_lRIA
- Content-Type: application/json; charset=utf-8
Body:
- {
- "CurrentProfile": "Portfolio Admin",
- "Relations": [{
- "FromRef" : "95-61-0",
- "Property" : "ResponsibleUser",
- "ToRef" : "421-862-0"
- },
- {
- "FromRef" : "95-61-0",
- "Property" : "Applications",
- "ToRef" : "76-2518-0"
- }]
- }
In the service call, two references are defined. Only one of the references were created because for the second relation, the referenced object does not exist in the Alfabet database.
Response of the service call:
- {
- "NotFound": {76-2518-0},
- "Count": 1
- }