Entity In Use

Entity is being referenced by other entities

Purple gradient wave Purple wave used to give a visual break between the header and body of the page.

Summary

The entity you are attempting to delete is currently referenced by another entity and so can't be deleted at this time.

For example, if you attempt to delete a Company that has Employees assigned to it then you will receive this error.

curl -X DELETE -H "Authorization: ApiKey {ApiKey}" https://api.youmanage.co.uk/Companies/6
{
  "error": {
    "code": "YM0055",
    "reference": "https://developer.youmanage.co.uk/api/errors/ym0055",
    "target": null,
    "message": "Can not complete this operation as the entity is currently in use",
    "details": null
  }
}

   

Solution

As the entity is referenced elsewhere, it cannot be amended/removed at this time. You will need to amend any entities that reference the entity you are attempting to delete to point to another valid entity.

Following on from the example in the summary, if you have employees assigned to a company that you want to delete you first need to search for all the employees that are assigned to that company:

curl -H "Authorization: ApiKey {ApiKey}" https://api.youmanage.co.uk/Employees?Company=n%47a

[
  {
    "id": 203,
    "manager": "Alex Ball",
    ...
  }
]

For each employee that is returned, you will then have to reassigned the employee to a different company

curl -i -X PATCH --data "{ \"Company\": \"Awesome Inc.\" }" \
  -H "Content-Type: application/json" \
  -H "Authorization: ApiKey {ApiKey}" \
  https://api.youmanage.co.uk/Employees/203
HTTP/1.1 204 No Content

And then finally once all references to the company have been removed you can reissue the initial delete command and the company should be deleted.

curl -i -X DELETE -H "Authorization: ApiKey {ApiKey}" https://api.youmanage.co.uk/Companies/6
HTTP/1.1 204 No Content