Duplicate an Item

Definition

POST /apis/v2/{SERVICE_ID}/item/duplicate

Description

Duplicate a specific item.

Details:

  • It will create a new item with the content of the initial one but with a new identifier.
  • The name must be different and the application key should be the user’s selected application key.

Permissions

The user needs to have the permissions:

SERVICE_ID=read && SERVICE_ID=edit

To duplicate an item, the two conditions below must be verified:

Parameters

The body parameter is a JSON object containing the old and the new identifiers.

The new name must validate the rules of the service’s item’s name.

Example:

{
    "oldId": {
         "appKey": "",
         "name": "Well-Network-Plant-Approver"
    },
    "newId": {
         "appKey": "",
         "name": "Well-Network-Plant-Approver_Duplicated"
    }
}

Response

HTTP code Reason
200 Success
400 Invalid parameter count or content
403 Unauthorized
404 Not found
500 Unexpected exception

When the query is successful, the HTTP response is a 200 OK and returns the facade of the duplicated item.

{
    "appKey": "",
    "name": "Well-Network-Plant-Approver_Duplicated",
    "description": "Well-Network-Plant-Approver",
    "calculatedContentMode": "EDITABLE",
    "appInfo": "",
    "lastModifiedBy": "roxane.mace@amalto.com",
    "lastModifiedDate": 1520933597027,
    "revisionId": "8d20bda1ce77b3ff0ce02da0b8e9b48d"
}

If the request parameter is null, the HTTP response is a 400 Invalid parameter:

{
    "status": 400,
    "code": 400,
    "message": "Unexpected error duplicating the item in the configuration!",
    "link": null,
    "developerMessage": "Invalid parameter count or content: the ids cannot be null.",
    "conflictInformation": null
}

If the user does not have the right permissions, the HTTP Response will be a 403 Unauthorized:

{
    "status": 403,
    "code": 403,
    "message": "Unauthorized: you need to have permission tables=edit-table.",
    "link": null,
    "developerMessage": "Requires permission tables=edit-table",
    "conflictInformation": null
}

If the original item is not found, it will return a 404 Not found:

{
    "status": 404,
    "code": 404,
    "message": "Unexpected error duplicating the item in the configuration! Item 'Well-Network-Plant-Approver' is not found.",
    "link": null,
    "developerMessage": "Not found: the item 'Well-Network-Plant-Approver' is not found.",
    "conflictInformation": null
}