Zain Sarwar
Zain Sarwar

Reputation: 1406

How do I call the Delete API call in CopyLeaks?

I have been trying to delete certain scans I have made using the API. Now, when I try to do that using documentation provided here : https://api.copyleaks.com/documentation/v3/education/delete, I keep getting the following error which is : b'{"scans":["The scans field is required.","Cannot be null"]}'

I am following the documentation for the API to create my json object and pass it to request.patch but I keep getting the same error.

Just to be sure I am not doing this incorrectly, here is my code :

myobj = json.dumps({'scans':[{'id':'43973'}],'purge':'false'})


response = requests.patch('https://api.copyleaks.com/v3.1/education/delete', headers=headers, data=myobj)

If someone could provide some guidance with regards to this, it would be really nice.

Upvotes: 0

Views: 58

Answers (1)

Guevara Brik
Guevara Brik

Reputation: 49

make sure you set the content type header to application/json like so:

'Content-type': 'application/json',

EDIT:

the headers object should look like this:

headers = {
'Content-type': 'application/json',
'Authorization': 'Bearer YOUR_TOKEN'

}

Upvotes: 0

Related Questions