Example URLs for modifying relationships - Intergraph Smart API Manager - 2020 (4.0) - Help

Intergraph Smart API Manager Help

Language
English
Product
Intergraph Smart API Manager
Search by Category
Help
Smart API Manager Version
4.0

Smart APIs provide all the functionality required to create, update, or delete relationships between entity instances.

You can make HTTP PUT (or POST) requests to create or update relationships between entity instances, while HTTP DELETE is used to delete relationships.

Of course, the relationships must exist in the Smart API's Entity Data Model (metadata).

Creating and deleting relationships between entities is enabled in OData using a reference URI ($ref). See the following OData documentation for details: OData Relationship Operations.

The following topics provide example URLs for modifying relationships.

Example URL/request body for creating a relationship

The following URL and request body provide an example of creating a new relationship between a Vessel and Nozzle via an HTTP PUT request.

PUT https://sam.acmeserver.com/SampleService/Sppid/v3/Sites('Site A')/Plants('Plant A')/Vessels('3')/Nozzles/$ref

{

"@odata.id":"https://sam.acmeserver.com/SampleService/Sppid/v3/Sites('Site A')/Plants('Plant A')/Nozzles('107')"

}

The request URL contains the specific instance of an entity, Vessels('3'), plus the navigation property (Nozzles) plus $ref.

The request body contains a JSON object with the @odata.id annotation value set to the URL for the related entity instance.

Example URL/request body for updating a relationship

The following URL and request body provide an example of updating a relationship, changing the parent Vessel for a Nozzle via an HTTP PUT request.

PUT https://sam.acmeserver.com/SampleService/Sppid/v3/Sites('Site A')/Plants('Plant A')/Nozzles('104')/Parent/$ref

{

"@odata.id":"https://sam.acmeserver.com/SampleService/Sppid/v3/Sites('Site A')/Plants('Plant A')/Vessels('3')"

}

The request URL contains the specific instance of the entity, Nozzles('104'), plus the navigation property (Parent) plus $ref.

The request body contains a JSON object with the @odata.id annotation value set to the URL for the related entity instance.

Example URL for deleting a relationship

The following URL provides an example of deleting a relationship between a Vessel and a Nozzle via an HTTP DELETE request.

DELETE https://sam.acmeserver.com/SampleService/Sppid/v3/Sites('Site A')/Plants('Plant A')/Vessels('3')/Nozzles/$ref?$id=https://sam.spclouddave.com/SampleService/Sppid/v3/Sites('Site A')/Plants('Plant A')/Nozzles('104')

The HTTP DELETE request cannot have a body, so the $id query parameter holds the value to the related entity instance for which to delete the relationship.