Copy resources via REST API

Hello. I see in the documentation that it's possible to copy resources using the POST method. 

Here is what documentataion shows: http://<host>:<port>/jasperserver[-pro]/rest_v2/resources/path/to/folder?<arguments>

And there are arguments: "createFolders" and "overwrite".

But it's not clear how exactly I should pass source and destination. Can anybody show the example, please? For example, if I want to copy file1 from folder1 to folder2

valeriya0606's picture
Joined: May 25 2021 - 2:49am
Last seen: 1 year 3 months ago

1 Answer:

example written in bash to copy sample report to the "temp" directory:

copy_resp=$(curl -k -X POST "http://localhost:8080/jasperserver-pro/rest_v2/resources/temp?j_username..." -H "Accept: application/json" -H "Content-Location: /public/Samples/Reports/01._Geographic_Results_by_Segment_Report")
if [[ $upload_resp == *"errorCode"* ]]; then
    echo "Copy failed"
else
   copy_uri=$(echo ${copy_resp} | jq -r '.uri')
   echo "Copied report to: "$copy_uri
fi
 

jonmcano's picture
330
Joined: Sep 20 2016 - 8:21am
Last seen: 1 year 6 months ago
Feedback
randomness