Forums

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

Getting 400 error while trying to make a search

Tamara Yulevich November 2, 2023

Hi everyone, 

 

I want to understand why I get this 400 error running this code: 

```

// Using the 'axios' library for HTTP requests
const axios = require('axios');

// Jira server and credentials
const jiraServer = <server_name>;
const username = <user_name>;
const apiToken = <token>

// Filter open Jira tickets for a specific user
async function filterOpenTicketsForUser(username) {
try {
// Use basic authentication with your Jira credentials
const auth = {
username,
apiToken
};

// Define your JQL query to filter open tickets for a specific user
const jqlQuery = `assignee = ${username} AND status = Open`;

// Make a GET request to Jira API
const response = await axios.get(`${jiraServer}/rest/api/2/search`, {
auth,
params: {
jql: jqlQuery,
},
});

// Output the Jira issues
const issues = response.data.issues;
issues.forEach((issue) => {
console.log(`Key: ${issue.key}, Summary: ${issue.fields.summary}`);
});
} catch (error) {
console.error('Error:', error);
}
}

// Call the function to filter open tickets for a specific user
filterOpenTicketsForUser(username);
```

1 answer

0 votes
Tamara Yulevich November 2, 2023

Never mind, there was a problem with the user name, how do I get my user name?

Tamara Yulevich November 2, 2023

Without the user name I get 0 tickets, how is that possible? I work in a company that has thousands of tickets: 

{ startAt: 0, maxResults: 50, total: 0, issues: [] }

Suggest an answer

Log in or Sign up to answer
DEPLOYMENT TYPE
CLOUD
PRODUCT PLAN
PREMIUM
TAGS
AUG Leaders

Atlassian Community Events