Sharepoint API CopyTo on behalf of the user not accessible
So I'm creating an application to manipulate Sharepoint via API, and I didn't find any solution to my problem within the documentations.
The problem is that I cannot copy a file to another existing folder with the copyTo API method, even though I can get files and upload files excellently through the Sharepoint API.
In the admin center I have set delegated AllSites.FullControl rights to my application, consented by admin.
The request I'm sending:
https://{tenant}.sharepoint.com/sites/TestSite/_api/web/GetFolderByServerRelativeUrl('Shared%20Documents/testFolder')/files('testFile.txt')/copyTo(strnewurl='/sites/TestSite/folders/Shared%20Documents/testFolder2', boverwrite=true)
Method: POST
Headers:
Authorization: Bearer {token}
Accept: application/xml
The response I get is:
<?xml version="1.0" encoding="utf-8"?>
<m:error xmlns:m="http://schemas.microsoft.com/ado/2007/08/dataservices/metadata">
<m:code>-2147024891, System.UnauthorizedAccessException</m:code>
<m:message xml:lang="en-EN">Access denied</m:message>
</m:error>