Created
April 25, 2019 08:31
-
-
Save mperesson/d872ddcdb7e12559d7e84c4693c928ae to your computer and use it in GitHub Desktop.
Kayako API remove spam
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import requests | |
from requests.auth import HTTPBasicAuth | |
auth = HTTPBasicAuth('email', 'password') | |
while True: | |
r = requests.get('https://COMPANY.kayako.com/api/v1/search?fields=id&query=QUERY&offset=0&limit=30&resources=CONVERSATIONS', auth=auth) | |
ids = [] | |
j = r.json() | |
if len(j['data']) == 0: | |
break | |
for data in j['data']: | |
ids.append(str(data['id'])) | |
print(ids) | |
trash_url = 'https://COMPANY.kayako.com/api/v1/cases/trash?ids={}'.format(','.join(ids)) | |
requests.put(trash_url, auth=auth) | |
print('trashed') | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment