Ayoub Idelhoussain Ayoub Idelhoussain - 24 days ago 6
reST (reStructuredText) Question

copy model folder using Rest API

I'm working with Alfresco Community edition , and i wanna Copy a folder using the Api only because i don't have access to js CMIS , i found so Url to post my Data to but i'm always blocked by an http 401 error , even though my ticket is valide and i also add to the header the authorisation data.

i have both the source folder nodRef :

this is the model folder :

workspace://SpacesStore/aeeaca0a-89bf-4294-8506-315ecd7d18f2


and the destination parent Id (where the copied folder should be :

workspace://SpacesStore/48fcc674-fe08-4802-963b-ca8e2ccd1a62


any help from you guys is appreciated . Thank you

from the documentation i do a POST to this adress
/alfresco/s/slingshot/doclib/action/copy-to/node/{store_type}/{store_id}


in the header i need
content-type:application/json
and
authorization : basic 'base64_encode(ROLE_TICKET:$ticket'

Answer
  1. Authorization, you can use:

    • query param PARAM_ALF_TICKET = "alf_ticket":

      url?alf_ticket=your-ticket
      
    • or header AUTHORIZATION_HEADER = "Authorization":

      Authorization: Basic base64_encode(user+":"+password)
      
  2. Copy Node REST API (available in Alfresco 5.2 and newer versions):

    curl -X POST 
    --header 'Content-Type: application/json' 
    --header 'Accept: application/json' 
    --header 'Authorization: Basic eW91LWFyZTp0aGUtYmVzdC1oYWNrZXI7KQ==' 
    -d '{
      "targetParentId": "new-parent-folder-node-id",
      "name": "new-node-name"
    }' 
    'http://localhost:8080/alfresco/api/-default-/public/alfresco/versions/1/nodes/{node-id}/copy'