Using the API to aggregate customer emails



2021년 2월 17일에 게시됨

Hi,

I am trying to search by tickets, find submitter_id from results, and compare it to users id to print out their respective emails. 

I currently have the code together for it, but it only works for smaller results.
Bigger results spit back a 422 error.

Let me know if there are any good guides on similar queries. 

# imports
import requests

# my authorization credentials
credentials = 'user', 'pw'
session = requests.Session()
session.auth = credentials
zendesk = 'https://xxx.zendesk.com/'

# query for tix 
url = zendesk + '/api/v2/search.json?query=test123'
topic_posts = []

while url:
response = session.get(url)
if response.status_code != 200:
print('Error with status code {}'.format(response.status_code))
exit()
data = response.json()
topic_posts.extend(data['results'])
url = data['next_page']

# pull submitter_id's 
newlist1 = []
for post in topic_posts:
newlist1.append(post['submitter_id'])

url = zendesk + '/api/v2/users.json'
topic_posts2 = []

while url:
response = session.get(url)
if response.status_code != 200:
print('Error with status code {}'.format(response.status_code))
exit()
data = response.json()
topic_posts2.extend(data['users'])
url = data['next_page']

# pull emails from user list
for post in topic_posts2:
if post['id'] in newlist1 and post['id'] != 'None':
print(post['email'])


0

2

댓글 0개

댓글을 남기려면 로그인하세요.

원하는 정보를 못 찾으셨나요?

새 게시물