Create Relationship Operation

The create relationship operation adds a new relationship between two entities in a Context Graph model. The relationship metadata must already exist in the Context Graph model.

HTTP PUT URL Format

The request is specified as follows. The Spectrum server supports both HTTP and HTTPS.

PUT http://server_name:port/rest/DataHub/operations/modelName/relationships/relationshipLabel?query_parameters

URL Path Elements

modelName
The name of the Context Graph model.
relationshipLabel
The name of the relationship label connecting two entities in a model.

Query Parameters

Parameter Type Required Description
sourceID string yes The source ID of the entity that connects a relationship. This parameter specifies an entityType:entityLabel value pair.
targetID string yes The target ID of the entity that connects a relationship. This parameter specifies an entityType:entityLabel value pair.
uniqueID string no The value that distinguishes a relationship when there are multiple relationships with the same label connecting two entities in a model.

URL PUT Body Format

Content-Type:application/json {Property Name-Value Pairs}

Optionally, you can specify a property name and value pair for any existing property in the following format. A property is not created if it contains a null or empty value. The property name pairs are formatted as follows:

{
    "Property1":"Value1",
    "Property2":"Value2",
    ...
}

Response

The operation returns the status code "200 OK" when it is successful. The operation returns the status code 500 (Error) when it fails.

Create relationship with JSON response

The following request creates a Roomate relationship label in the "911" model between two person entities and adds the following properties: "Date" and "Rank".

PUT http://localhost:8080/rest/DataHub/operations/911/relationships/Roomate?​sourceID=Person:Ahmed%20al-Haznawi&​targetID=Person:Ziad%20Jarrah

Body:

{
    "Date":1275782400000,
    "Rank":"0"
}
            

Response:

{
     "success":"200 OK"
}
Note: Date, time, and date-time property values are UNIX Epoch time values formatted as long data type in both requests and responses.

Create relationship with same label

The following creates a Roomate relationship label in the "911" model where the relationship ID between two person entities is equal to "4".

PUT http://localhost:8080/rest/DataHub/operations/911/relationships/Roomate?​sourceID=Person:Ahmed%20al-Haznawi&​targetID=Person:Ziad%20Jarrah&​uniqueID=4