0

I'm not able to pass the user input into JQL query? I've tried no of alternative but nothing works.

Here is the code.

project_name=raw_input("Please give the project name:  ")
reporter_name=raw_input("Please provide the name of creator:   ")
date_from=raw_input("Please provide the time interval for which you want issues: From ")
date_to=raw_input("Please provide the time interval for which you want issues: To ")"""

total_issues = jira.search_issues('project = %s AND reporter = %s AND created > %s and created < %s' % (projectname, reportername, datefrom, dateto))
print total_issues

It gives me: jira.exceptions.JIRAError

traceback (most recent call last):
  File "jiradetailsizmirtomtom.py", line 27, in <module>
    for i in jira.search_issues('project = project_name AND reporter = reporter_name AND created > date_from and created < date_to'):
  File "/Library/Python/2.7/site-packages/jira/client.py", line 1747, in search_issues
    issues = self._fetch_pages(Issue, 'issues', 'search', startAt, maxResults, search_params)
  File "/Library/Python/2.7/site-packages/jira/client.py", line 397, in _fetch_pages
    resource = self._get_json(request_path, params=page_params, base=base)
  File "/Library/Python/2.7/site-packages/jira/client.py", line 2172, in _get_json
    r = self._session.get(url, params=params)
  File "/Library/Python/2.7/site-packages/jira/resilientsession.py", line 150, in get
    return self.__verb('GET', url, **kwargs)
  File "/Library/Python/2.7/site-packages/jira/resilientsession.py", line 146, in __verb
    raise_on_error(response, verb=verb, **kwargs)
  File "/Library/Python/2.7/site-packages/jira/resilientsession.py", line 56, in raise_on_error
    r.status_code, error, r.url, request=request, response=r, **kwargs)
jira.exceptions.JIRAError

Can we really pass variable to JQL query? Does JQL allows this?

wittich
  • 2,079
  • 2
  • 27
  • 50
  • in the line `date_to=` is at least one `"`-quote too much... is that only a copy error? – wittich Jul 21 '17 at 06:07
  • Also, in this example you have variables `date_to` etc., but the query line has `dateto`. The exception shows that this is not the actual problem though, but fixing your example would make it less tedious for us to look at. – Teemu Risikko Jul 21 '17 at 06:11
  • The exception says `for i in jira.search_issues('project = project_name AND reporter = reporter_name AND created > date_from and created < date_to'):`. Is this really how it is in your code? You have the string formatting with % in your example but the exception does not match that at all. – Teemu Risikko Jul 21 '17 at 06:12
  • I got it working, thanks! – Lakshveer Singh Jul 22 '17 at 09:39

0 Answers0