How to get percentage matching in copyleakes Export API using python

144 Views Asked by At

I'm working on copyleaks api using python. I was able to successfully complete Account Methods and Scans Methods. then when I tried to export the report in that copyleaks export api I am getting only response code and getting any details of that response like matching percentage. How can we achieve this using python.

1

There are 1 best solutions below

0
On

After successfully submitting a scan and the scan has already been scanned and successfully finished by our services, you will be able to find information about the matching percentage in the status webhook you specified in your scan submit request.

However if you want to download the pdf report of your scan, all you have to do is to send an export request to this endpoint POST https://api.copyleaks.com/v3/downloads/{scanId}/export/{exportId}

With these headers:

Content-Type:application/json
Authorization:Bearer YOUR ACCESS TOKEN

and the following body:

{
  pdfReport": {
    "verb": "POST",
    "endpoint": "https://yourserver.com/export/export-id/pdf-report"
  },
  "completionWebhook": "https://yourserver.com/export/export-id/completed",
  "maxRetries": 3
}

The pdf report is going to be then uploaded to the endpoint specified by you.

Here is a python example:


import requests
import json

headers = {
    'Content-type': 'application/json',
    'Authorization': 'Bearer YOUR-LOGIN-TOKEN'
}

myobj = json.dumps({'pdfReport':{'verb':'POST','endpoint':'https://yourserver.com/export/export-id/pdf-report'},'completionWebhook':'https://yourserver.com/export/export-id/completed','maxRetries':3})

response = requests.post('https://api.copyleaks.com/v3/downloads/scan-id/export/export-id', headers=headers, data=myobj)

EDIT:

NOTE: in order for you to be able to export a pdf report of your scan you have to set the properties.pdf.create field to true in the scan submit request.