Trouble with JIRA API: Created date search causing errors

Hey guys, I’m stuck with a JIRA API issue. I can search for reporter and project just fine, but adding a creation date throws an ‘Invalid argument’ error. Here’s what I’ve got:

# This works:
api_url = 'search?jql=(reporter=bob OR author=bob) AND (project in (app1, app2, app3))'

# This breaks:
api_url = 'search?jql=(reporter=bob OR author=bob) AND (project in (app1, app2, app3) AND (created > 2024-01-01))'

I’ve tried different quote styles and escaping, but no luck. Weirdly, the query works fine directly in JIRA. Any ideas what I’m doing wrong with the API call? Thanks!

I’d suggest breaking down your query into smaller parts to isolate the issue. Start with just the date filter and gradually add complexity. Something like this might work:

api_url = ‘search?jql=created > “2024-01-01” AND project in (app1, app2, app3) AND (reporter = bob OR author = bob)’

Note the escaped quotes around the date and the rearranged order. JIRA’s API can be sensitive to query structure. Also, ensure you’re using the correct API version - some older versions have quirks with complex queries.

If you’re still stuck, try using JIRA’s REST API browser (usually found at /rest/api/latest/). It’s a great tool for testing and debugging API calls directly in your JIRA instance.

I’ve encountered similar issues with JIRA’s API before, and it can be frustrating when queries that work in the UI fail through the API. From my experience, the problem might be related to how the API handles parentheses and date formats.

Try restructuring your JQL query like this:

api_url = 'search?jql=reporter=bob OR author=bob AND project in (app1, app2, app3) AND created > "2024-01-01"'

Notice I’ve removed some parentheses and added quotes around the date. JIRA’s API can be picky about date formatting, so using quotes often helps. Also, make sure your date is in the correct timezone - JIRA uses the instance’s timezone by default.

If this doesn’t work, you might need to URL-encode your query parameters. Some libraries do this automatically, but if you’re constructing the URL manually, you’ll need to encode special characters.

Lastly, double-check your API permissions. Sometimes, date-based queries require additional access levels. Hope this helps!