Skip to content

Copy attachments

This REST call allows you to copy attachments from a source field to a target attachment field. The source and target attachment field can be part of different documents.

URL

api/v1/documents/copyAttachments

Method

POST or PUT

URL parameters
Parameter Type Required Description
environmentId String Yes The ID of the environment.
Header Parameters
Parameter Type Required Description
Content-Type String Yes Provide the content type of your call. Only application/json is supported.
X-User-Id String Yes The ID of the user who wants to trigger the REST action. This ID is returned by the authentication call.
X-Auth-Token String Yes The authentication token that the authentication call returned.
Body

The body is a JSON array that contains an object for each attachment that should be copied. The object has two fields: source and target. The parameters of the _source object are:

Field Type Required Description
ddName String Yes The name of the document definition on which the source document is based.
_id String No The internal ID of the source document. Either the __id_ or externalId field should be supplied.
externalId String No The external ID of the source document. Either the __id_ or externalId field should be supplied.
fieldName String Yes The name of the field from which the attachments should be copied.
lineName String No If the attachment field is part of a line, enter the name of the line here.
lineId String No The ID of the line from which the attachments should be copied.
lineExternalId String No The external ID of the line from which the attachments should be copied. If the lineName field has a value, either the lineId or lineExternalId should be entered.
fileNames String Array No An array of the names of attachments that should be copied. If neither the field fileNames nor fileIds has been supplied, all attachments are copied.
fieldIds String Array No An array of the IDs of attachments that should be copied. If neither the field fileNames nor fileIds has been supplied, all attachments are copied.

The parameters of the target object are:

Field Type Required Description
ddName String Yes The name of the document definition on which the target document is based
_id String No The ID of the target document. Either the __id_ or externalId field should be supplied.
externalId String No The external ID of the target document. Either the __id_ or externalId field should be supplied.
fieldName String Yes The name of the field to which the attachments should be copied.
lineName String No If the attachment field is part of a line, enter the name of the line here.
lineId String No The ID of the line to which the attachments should be copied.
lineExternalId String No The external ID of the line to which the attachments should be copied. If the lineName field has a value, either the lineId or lineExternalId should be entered.
clearField Boolean No A boolean value that indicates whether the existing attachments should be removed from the field. If this field is not provided, the field is not cleared.
Response

A JSON object with the status code of the HTTP response and possibly error information.

Example

curl /api/v1/documents/copyAttachments?environmentId=a83rh4aX5nzBsGL3S \
    -H "X-Auth-Token: 6IrqyFhbKjpyJZ_NX6dwLmRNxWk0OVffE8aBfauNKUG" \
    -H "X-User-Id: a6gA9rYaGTFKPrT5P" \
    -H "Content-Type: application/json" \
    -X POST \
    -d '[
        {
            "source": {
                "ddName":"menuItem",
                "_id":"3DKKq68tvhpu9bk24",
                "fieldName":"picture",
                "fileIds": ["cmFCNKrx5XE659zP4", "r7LWRi5Rkz8a98Gfm"]
            },
            "target": {
                "ddName":"menuItem",
                "_id":"90f56538c1fb334258952bda",
                "fieldName":"picture",
                "clearField":"true"
            }
        },
        {
            "source": {
                "ddName":"menuItem",
                "_id":"3DKKq68tvhpu9bk24",
                "lineName":"ingredients",
                "fieldName": "preparationInstructions",
                "lineId" : "74240700f347e0b8063b940d",
                "fileNames": ["largescreenshot.png"]
            },
            "target": {
                "ddName":"menuItem",
                "_id":"90f56538c1fb334258952bda",
                "fieldName":"preparationInstructions",
                "lineName": "ingredients",
                "lineExternalId": "12345",
                "clearField":"true"
            }
        }
    ]'