I’m currently building a jql issue search via the rest api of Atlassian.
Here is my code, or better the code provided by Atlassian:
const fetch = require('node-fetch')
fetch('https://mydomain.atlassian.net/rest/api/3/search?jql=jqlsearch', {
method: 'GET',
headers: {
Authorization: `Basic ${Buffer.from(
'username', 'apikey'
).toString('base64')}`,
Accept: 'application/json'
}
})
.then(response => {
console.log(
`Response: ${response.status} ${response.statusText}`
)
return response.text()
})
.then(text => console.log(text))
.catch(err => console.error(err))
I now receive the errormessage "Error at Script :1:77". And to be honest, I’m struggling with troubleshooting that, I don’t know what that error message is standing for.
My first guess was that there is an error in line 1 at the 77th character but there is no 77th character in line 1.
Excited to hear what’s wrong here. (probably it’s a layer 8 problem 🙂 )
And forgive me my probably basic question but I couldn’t find an answer in my google search.
I tried to change the fetch message with a different jql search and tried another domain.
But I think it’s more a problem somewhere in the code than a connectionerror.
PS: Here is the documentation provided by Atlassian: https://developer.atlassian.com/cloud/jira/platform/rest/v3/api-group-issue-search/#api-rest-api-3-search-get
Best Regards
Niklas
2
Answers
The fetch error is too long, so I post it in a single comment:
FetchError: request to https://mydomain.atlassian.net/rest/api/3/search?jql=jqlsearch failed, reason: getaddrinfo EAI_AGAIN mydomain.atlassian.net at ClientRequest.<anonymous> (/usr/share/nodejs/node-fetch/lib/index.js:1697:14) at ClientRequest.emit (events.js:314:20) at TLSSocket.socketErrorListener (_http_client.js:427:9) at TLSSocket.emit (events.js:314:20) at emitErrorNT (internal/streams/destroy.js:92:8) at emitErrorAndCloseNT (internal/streams/destroy.js:60:3) at processTicksAndRejections (internal/process/task_queues.js:84:21) { type: 'system', errno: 'EAI_AGAIN', code: 'EAI_AGAIN' }
Edit: I'm trying to run the script at StackBlitz as a Test, is that the reason for the fetch error?
It seems like you’re using the node-fetch library to make a REST API call to retrieve Jira issues from Atlassian. The error message "Error at Script :1:77" usually indicates an issue with the script itself, rather than a connection error. In your code snippet, I don’t see any issues with the line numbers provided.
However, I do see a potential issue with how you’re encoding the
Authorization
header. You should be using the formatusername:apikey
before encoding it in base64. Also, make sure to replace'username'
and'apikey'
with your actual Jira username and API token.Here’s the corrected version of your code:
Please make sure to replace
'your-jira-username'
and'your-jira-api-key'
with your actual Jira username and API token.If you’re still encountering the error after making these changes, please provide more details about the error message you’re receiving, including the full error stack trace if available.