Forums

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

FORGE API JIRA difference between search in browser and resolver response

Felipe Rodriguez
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
July 28, 2023

Hello community,

I have doubts, when I make a query to get the issues between dates through 

https://mydomain.atlassian.net/rest/api/3/search?jql=createdDate%20>%20202323-07-01%20AND%20createdDate%20<%20202023-07-30

I get the issues correctly.

 

But when I do it through the resolver I get all the issues, but the statement is the same.



resolver
.define('fetchIssuesByDate', async (req) => {

const
startDate = req.payload.startDate.substring(0,10);

const endDate = req.payload.endDate.substring(0, 10);

const jql = `jql=created>${startDate} AND created<=${endDate}`;

const response = await api

.asUser()

.requestJira(route`/rest/api/3/search?${jql}`);

const data = await response.json();

const issues = transformIssuesData(data);



return issues;

})

// aux function

function transformIssuesData(data) {

const issueKeys = [];

for (const issue of data.issues) {

issueKeys.push({

"key": issue.key,

"id": issue.id,

"timespent": issue.fields.timespent,

"created": issue.fields.created,

"summary": issue.fields.summary

});

}

return issueKeys;

}

1 answer

1 accepted

0 votes
Answer accepted
Felipe Rodriguez
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
July 30, 2023

I found the way to search by JQL sentence in doc Jira API. 

resolver.define('getIssuesAndFilterByDate', async (req) => {



const startDate = format(new Date(req.payload.startDate), 'yyyy-MM-dd');

const endDate = format(new Date(req.payload.endDate), 'yyyy-MM-dd');



const jql = `created >= "${startDate}" AND created <= "${endDate}"`;

const bodyData = {

expand: ["names", "schema"],

fields: ["summary", "status", "assignee", "timespent"],

fieldsByKeys: false,

jql: jql,

startAt: 0,

};

const response = await api.asUser().requestJira(route`/rest/api/3/search?$`, {

method: 'POST',

headers: {

'Accept': 'application/json',

'Content-Type': 'application/json'

},

body: JSON.stringify(bodyData), // Convertir el objeto en una cadena JSON

});

console.log(`Response: ${response.status} ${response.statusText}`);

const data = await response.json();

//console.log(data);

return data;

});

Suggest an answer

Log in or Sign up to answer
DEPLOYMENT TYPE
CLOUD
PRODUCT PLAN
STANDARD
PERMISSIONS LEVEL
Product Admin
TAGS
AUG Leaders

Atlassian Community Events