API REST Enregistrer le fichier Python

import requests
import base64

pat = ""
authorization = str(base64.b64encode(bytes(':'+pat, 'ascii')), 'ascii')
url="https://auditservice.dev.azure.com/{org}/_apis/audit/downloadlog?  
format=csv&startTime=2020-07-01T00.00.00&endTime=2020-10-15T16.00.00&api-version=6.1-   
preview.1"

headers = {
 'Accept': 'application/json',
 'Authorization': 'Basic '+authorization
}

response = requests.get(url, headers=headers)

with open("/Users/username/logs/logs.csv", "w") as text_file:
    text_file.write(response.content)
Clear Curlew