Twins - DigitalTwins AddRelationship
Adds a relationship between two digital twins. Status codes:
- 200 OK
- 400 Bad Request
- InvalidArgument - The digital twin id, relationship id, or payload is invalid.
- InvalidRelationship - The relationship is invalid.
- OperationNotAllowed - The relationship cannot connect to the same digital twin.
- ValidationFailed - The relationship content is invalid.
- 404 Not Found
- DigitalTwinNotFound - The digital twin was not found.
- TargetTwinNotFound - The digital twin target of the relationship was not found.
- 412 Precondition Failed
- PreconditionFailed - The precondition check (If-Match or If-None-Match) failed.
PUT https://digitaltwins-hostname/digitaltwins/{id}/relationships/{relationshipId}?api-version=2023-10-31
URI Parameters
Name | In | Required | Type | Description |
---|---|---|---|---|
id
|
path | True |
string |
The id of the digital twin. The id is unique within the service and case sensitive. |
relationship
|
path | True |
string |
The id of the relationship. The id is unique within the digital twin and case sensitive. |
api-version
|
query | True |
string |
The requested API version. |
Request Header
Name | Required | Type | Description |
---|---|---|---|
If-None-Match |
string |
Only perform the operation if the entity does not already exist. |
|
traceparent |
string |
Identifies the request in a distributed tracing system. |
|
tracestate |
string |
Provides vendor-specific trace identification information and is a companion to traceparent. |
Request Body
Name | Type | Description |
---|---|---|
relationship |
object |
The data for the relationship. |
Responses
Name | Type | Description |
---|---|---|
200 OK |
Relationship |
Success Headers ETag: string |
Other Status Codes |
Default response. Headers x-ms-error-code: string |
Security
oauth2
Type:
oauth2
Flow:
implicit
Authorization URL:
https://login.microsoftonline.com/common/oauth2/authorize?resource=0b07f429-9f4b-4714-9392-cc5e8e80c8b0
Examples
Create a relationship |
Create a relationship (with properties) |
Create a relationship
Sample request
PUT https://digitaltwins-hostname/digitaltwins/mySourceTwin/relationships/myRelationshipId?api-version=2023-10-31
{
"$targetId": "myTargetTwin",
"$relationshipName": "myRelationship"
}
Sample response
{
"$relationshipId": "myRelationshipId",
"$sourceId": "mySourceTwin",
"$targetId": "myTargetTwin",
"$relationshipName": "myRelationship",
"$etag": "W/\"1553dbf5-0052-4be8-bea8-46269075b503\""
}
Create a relationship (with properties)
Sample request
PUT https://digitaltwins-hostname/digitaltwins/mySourceTwin/relationships/myRelationshipId?api-version=2023-10-31
{
"$targetId": "myTargetTwin",
"$relationshipName": "myRelationship",
"relationshipProperty1": 1,
"relationshipProperty2": "some value"
}
Sample response
{
"$relationshipId": "myRelationshipId",
"$sourceId": "mySourceTwin",
"$targetId": "myTargetTwin",
"$relationshipName": "myRelationship",
"relationshipProperty1": 1,
"relationshipProperty2": "some value",
"$etag": "W/\"1553dbf5-0052-4be8-bea8-46269075b503\""
}
Definitions
Name | Description |
---|---|
Error |
Error definition. |
Error |
Error response. |
Inner |
A more specific error description than was provided by the containing error. |
Error
Error definition.
Name | Type | Description |
---|---|---|
code |
string |
Service specific error code which serves as the substatus for the HTTP error code. |
details |
Error[] |
Internal error details. |
innererror |
An object containing more specific information than the current object about the error. |
|
message |
string |
A human-readable representation of the error. |
ErrorResponse
Error response.
Name | Type | Description |
---|---|---|
error |
The error details. |
InnerError
A more specific error description than was provided by the containing error.
Name | Type | Description |
---|---|---|
code |
string |
A more specific error code than was provided by the containing error. |
innererror |
An object containing more specific information than the current object about the error. |