Python request returning status 400

Hello, I'm just getting to grips with the Freshdesk API. I am trying to write a query to return all tickets within a certain group that are open and am writing this :

r = requests.get("https://"+ domain +'"group_id:2043030657256%20AND%20(status:2)"', auth = (api_key, password))

but it returns status 400 when I run it, any idea where I'm going wrong? I can get other API requests working, but i'm clearly doing something wrong with the query request.

I've run into this too, and I can't figure out how to perform a query that filters tickets as you're trying to do. I noticed that the formatting of the queries is a little different depending on what you're querying in the API. For example when querying the Customer Satisfaction surveys, you don't seem to need 'query=' or double quotation marks. The below works fine:


I'm pretty new to this too, so I expect we're just missing something.

Update: I just spotted that the query response does in-fact tell you what the problem was. 

Mine is coming back with:

{'description': 'Validation failed',
 'errors': [{'field': 'query',
   'message': 'Unexpected/invalid field in request',
   'code': 'invalid_field'}]}

 I'm getting this response even when I copy/paste from the examples on Freshdesk's API page using standard fields, so perhaps something is amis. For example the query below (taken from the examples) gets the result above:


 So for now I'm all out of ideas!

@Gabriel, I just figured it out. We are both missing /search/ in our request URL. It's that simple!

When querying for specific tickets, all tickets, applying existing filters, or applying the basic filters mentioned here it's:


But when querying with a URL-encoded query for things like 'priority:4', it's:


The snippet below returned the tickets between the two date ranges as expected.



Hope that helps!

Login or Signup to post a comment