I want to parse and encode 6 param to my URL using Python



Posted Oct 24, 2022

See this example taken from here:

params = {

'query': 'type:ticket status:open', 
'sort_by': 'created_at',    
'sort_order': 'asc'

}

url = 'https://your_subdomain.zendesk.com/api/v2/search.json?' + urlencode(params)


But, I want to pass something like this:

params = {

'query': 'type:ticket status:solved', 

'query': 'tag:__deposits__,  # I don't know if this tag should go with ""

'query': created>2022-07-01,  

'query': created<2022-09-30,

'query': group:"customer support bla",  # This is a main contact type field

'query': group:"customer support blax2",  # This is a secondary contact type field

}

Finally I'm not able to make such call and an invalid syntax exception is raised. 

Can anyone of you guide me on how to make such call?

I appreciate your time and thanks in advance!

Note: Yes, I'm able to make successful calls using just this param. My script works well (connection, authentication, and so on) because I copied it from the documentation ;) 


0

4

4 comments

In case there is someone looking for a Python program to get data from Zendesk tickets, you can try this:
https://github.com/diegotco/zendesk_tickets_data

0


[SOLVED]

I was able to solve my questions:

1. Yes, a blank space is the only separator among each param?

2. Yes, all the code after : should be within ''

3. To search between dates, you can use, i.e:
created>2022-10-22 created<2022-10-24

4. To search by more than one tag, you should put all tags inside ""
 

0


Jack, thank you very much!

 

I've tried but with no results ;(

Questions:

-Is the blank space the only separator among each param?
-All the code after : should be within the ' ' ?
-Those dates, are ok to use them like this? created:>2022-10-22
-Should the params looks like this? 

params = {

'query': 'type:ticket status:open tag:__deposits__ created:>2022-10-22 created:<2022-10-24'

{

0


You should try put all of your search queries into one query like so: query: “type:ticket status:solved tag:__deposits__ …etc etc”

0


Sign in to leave a comment.

Didn't find what you're looking for?

New post