Copy and Move
Contents
Copy and Move#
Copying an object#
To copy a content object, send a POST
request to the /@copy
endpoint at the destination's URL with the source object specified in the request body.
The source object can be specified either by URL, path, UID or intid
:
POST /plone/@copy HTTP/1.1
Accept: application/json
Authorization: Basic YWRtaW46c2VjcmV0
Content-Type: application/json
{
"source": "http://localhost:55001/plone/front-page"
}
curl -i -X POST http://nohost/plone/@copy -H "Accept: application/json" -H "Content-Type: application/json" --data-raw '{"source": "http://localhost:55001/plone/front-page"}' --user admin:secret
echo '{
"source": "http://localhost:55001/plone/front-page"
}' | http POST http://nohost/plone/@copy Accept:application/json Content-Type:application/json -a admin:secret
requests.post('http://nohost/plone/@copy', headers={'Accept': 'application/json', 'Content-Type': 'application/json'}, json={'source': 'http://localhost:55001/plone/front-page'}, auth=('admin', 'secret'))
If the copy operation succeeds, the server will respond with status 200 OK, and return the new and old URL of the copied object:
HTTP/1.1 200 OK
Content-Type: application/json
[
{
"source": "http://localhost:55001/plone/front-page",
"target": "http://localhost:55001/plone/copy_of_front-page"
}
]
Moving an object#
To move a content object, send a POST
request to the /@move
endpoint at the destination's URL with the source object specified in the request body.
The source object can be specified either by URL, path, UID or intid
:
POST /plone/folder/@move HTTP/1.1
Accept: application/json
Authorization: Basic YWRtaW46c2VjcmV0
Content-Type: application/json
{
"source": "http://localhost:55001/plone/front-page"
}
curl -i -X POST http://nohost/plone/folder/@move -H "Accept: application/json" -H "Content-Type: application/json" --data-raw '{"source": "http://localhost:55001/plone/front-page"}' --user admin:secret
echo '{
"source": "http://localhost:55001/plone/front-page"
}' | http POST http://nohost/plone/folder/@move Accept:application/json Content-Type:application/json -a admin:secret
requests.post('http://nohost/plone/folder/@move', headers={'Accept': 'application/json', 'Content-Type': 'application/json'}, json={'source': 'http://localhost:55001/plone/front-page'}, auth=('admin', 'secret'))
If the move operation succeeds, the server will respond with status 200 OK, and return the new and old URL of the moved object:
HTTP/1.1 200 OK
Content-Type: application/json
[
{
"source": "http://localhost:55001/plone/front-page",
"target": "http://localhost:55001/plone/folder/front-page"
}
]
Copying or moving multiple objects#
Multiple objects can be moved or copied by giving a list of sources:
POST /plone/@copy HTTP/1.1
Accept: application/json
Authorization: Basic YWRtaW46c2VjcmV0
Content-Type: application/json
{
"source": [
"http://localhost:55001/plone/front-page",
"http://localhost:55001/plone/newsitem"
]
}
curl -i -X POST http://nohost/plone/@copy -H "Accept: application/json" -H "Content-Type: application/json" --data-raw '{"source": ["http://localhost:55001/plone/front-page", "http://localhost:55001/plone/newsitem"]}' --user admin:secret
echo '{
"source": [
"http://localhost:55001/plone/front-page",
"http://localhost:55001/plone/newsitem"
]
}' | http POST http://nohost/plone/@copy Accept:application/json Content-Type:application/json -a admin:secret
requests.post('http://nohost/plone/@copy', headers={'Accept': 'application/json', 'Content-Type': 'application/json'}, json={'source': ['http://localhost:55001/plone/front-page', 'http://localhost:55001/plone/newsitem']}, auth=('admin', 'secret'))
If the operation succeeds, the server will respond with status 200 OK, and return the new and old URLs for each copied or moved object:
HTTP/1.1 200 OK
Content-Type: application/json
[
{
"source": "http://localhost:55001/plone/front-page",
"target": "http://localhost:55001/plone/copy_of_front-page"
},
{
"source": "http://localhost:55001/plone/newsitem",
"target": "http://localhost:55001/plone/copy_of_newsitem"
}
]