I am trying out the Sharepoint API, but I am having troubles deleting anything. GET Calls, Creating folders and uploading files works like a charm, but deleting stuff is giving me head aches. I tried following the doc (https://docs.microsoft.com/en-us/sharepoint/dev/sp-add-ins/working-with-folders-and-files-with-rest), but every time I do a DELETE Call on either a folder or a file I get the same Error Message:
I also couldn't find any information to this error code. The site itself was created by the same account which does the API calls, so there shouldn't be any Permission Issues, right?
Code (I am using the sharepy python Library):
p = s.delete("https://example.sharepoint.com/sites/Test-Site/_api/web/GetFolderByServerRelativeUrl('/sites/Test-Site/Freigegebene Dokumente/test/Test Schuelerin')")
data = p.json()
write_to_file(data, "delete_folder.json")
The API Call itself is just on the Folder via GetFolderByServerRelativeUrl() and the sharepy.delete() should be the same as adding "X-HTTP-METHOD": "DELETE" to the header and using a POST call (altough I also tried that and the outcome was the same).
{
"error": {
"code": "-2130575251, Microsoft.SharePoint.SPException",
"message": {
"lang": "de-DE",
"value": "Die Sicherheits\u00fcberpr\u00fcfung f\u00fcr die Seite ist ung\u00fcltig und m\u00f6glicherweise fehlerhaft. Klicken Sie im Webbrowser auf die Schaltfl\u00e4che 'Zur\u00fcck', um den Vorgang zu wiederholen."
}
}
}
This is the error message I get (it's in german and says something along the lines of "The Security Check for this site is invalid and may contain errors")