0

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.

Zain Sarwar
  • 1,226
  • 8
  • 10

1 Answers1

0

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'

}

  • Thank you. I actually realized this yesterday. The team should update their api documentation. Also, random question. Is it possible to restrict comparison to certain files. I see that their is an option in the Submit aPi call named : ```properties.scanning.exclude.idPattern``` but it seems to only restrict comparison to one file. Is it possible to restrict access to a number of ids I provide? – Zain Sarwar May 11 '22 at 19:15
  • Hey Zain, could you provider me with the scan properties you are sending? Please take note that this pattern only applies to files submitted by you – Guevara Brik May 15 '22 at 10:13
  • Hey! These are my properties : ```myobj = json.dumps({'base64':BASE64_FILE_CONTENT,'filename':FILENAME,'properties':{'webhooks':{'status':'https://keyboard.yxchen.me:8443/copyleaks/{status}/' + str(scan_id)}, "scanning" : {'internet' : 'false', "repositories[]" : {"includeMySubmissions": 'true'}, 'copyleaksDb' : {"includeMySubmissions": 'true'}, "exclude" : {"idPattern" : '74042'}}, 'sandbox': 'false', 'action' : '0'}})``` Would like to make the "idPattern" a list of ids rather than just one string. Thanks! – Zain Sarwar May 15 '22 at 15:22