I’m facing an issue with the Jira REST API. While I can smoothly retrieve existing issues using GET requests, every attempt to create a new issue via POST requests results in a 500 internal server error. The authentication must be functioning properly because I’m able to read data without problems.
Here’s the Node.js code I’m working with:
createIssue: function(req, res) {
var Http = require('machinepack-http');
process.env.NODE_TLS_REJECT_UNAUTHORIZED = "0";
Http.sendHttpRequest({
url: '/rest/api/2/issue/',
baseUrl: 'https://jira.example.com',
method: 'post',
data: {
"fields": {
"project": {
"key": "TEST"
},
"summary": "Creating an issue via API",
"description": "This issue is created using REST API calls",
"issuetype": {
"name": "Story"
}
}
},
headers: {
"Authorization": "Basic dXNlcm5hbWU6cGFzc3dvcmQ="
},
}).exec({
serverError: function(result) {
res.send("Encountered an error: " + JSON.stringify(result))
},
success: function(result) {
res.send("Issue created successfully");
},
});
}
The error message I receive is:
{
"body": "{\"errorMessages\":[\"Internal server error\"],\"errors\":{}}",
"headers": "{\"server\":\"nginx/1.8.0\",\"date\":\"Thu, 16 Sep 2021 10:00:00 GMT\",\"content-type\":\"application/json;charset=UTF-8\",\"connection\":\"close\"}",
"status": 500
}
What might be causing this error?