Transactions

Transactions #

Transactions are used when an object requires multiple POST requests in order to be created. Endpoints that use transactions are marked with the Transaction tag in the OpenAPI document. The transaction ID is returned as TransactionID and is always an integer.

Items created as part of a transaction will not be visible until the transactions has been successfully committed. That includes children as well: a service request’s notes will not appear anywhere in the GUI.

Example #

Service requests are used for the example.

Create the service request #

Request:

POST .../maintenance/service_requests
Authorization: Bearer ...
{
    "service_request_type_id": 2
}

Response: 201 - Created

Location: .../maintenance/service_requests/6789
{
    "TransactionID": 12345
}

Attach attribute #

Attach attribute 137. For the purposes of this example, 137 is marked as mandatory. Request:

POST .../maintenance/service_requests/6789/attributes
{
	"attribute_definition_id": 137
}

Commit transaction #

Request:

POST .../transactions/12345/commit

Response: 400 - Bad Request

{
    "message": "Transaction failed validation.",
    "details": {
        "state": [
            "Attribute 545 is missing a value."
        ],
        "properties": []
    }
}

545 refers to the specific instance of the attribute attached to the given service request:

GET .../maintenance/service_requests/6789/attributes/545

Add attribute value #

PATCH .../maintenance/service_requests/6789/attributes/545
{
    "value": 123
}

Commit transaction #

Request:

POST .../transactions/12345/commit

Response: 201 - Created.