Forums

Articles
Create
cancel
Showing results for 
Search instead for 
Did you mean: 

I am getting 400 bad request when trying to get list of issues via jira rest api

robera worku June 13, 2018

here is my rest client code

exports.jqlBuilder = function(project, issueType, label, fromDate, toDate, thisMonth) {
var baseUrl = "https://xxx.atlassian.net/rest/api/2/search?jql=";
var extend = "&fields=issuetype,priority,assignee,status,description,created,creator,reporter,duedate,summary,resolution,updated,resolutiondate&expand=changelog&startAt=";
if (thisMonth) {
var req = encodeURIComponent("project = ") + "'" + project + "'" + encodeURIComponent(" AND issuetype = ") + "'" + issueType + "'" + encodeURIComponent(" AND labels in (") + label + encodeURIComponent(") AND created >= startOfMonth() AND created <= endofMonth()");
var searchUrl = baseUrl + req + extend;
return fetchedIssues(searchUrl);
}

and here is the fetchedIssues function

function fetchedIssues(searchUrl) {
return new Promise(function(resolve, reject) { 
getIssues(searchUrl).then((result) => { resolve(result) });})}

and here is my getIssues function

function getIssues(url) {
return new Promise(function(resolve, reject) { issue(url, startAt).then(function(result) {*
***}/*not important*/

function issue(url, startIndex) {
return new Promise(function(resolve, reject) {
client.get(url + startIndex, function(data, response) {
if (response.statusCode !== 200) {
reject(new Error('Fail with the status code: ' + response.statusCode));}
resolve(data); }) })}

 

this code executes 2 times and works on the second. i dont know why though

here is the response i get


{ errorMessages:
[ 'Error in the JQL Query: Expecting either \'OR\' or \'AND\' but got \'Jun\'. (line 1, character 71)' ],
errors: {} } 

1 answer

1 accepted

0 votes
Answer accepted
robera worku June 13, 2018

Found the problem. Not related to jira rest api.It was a condition i have set.

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events