Hello Jira developers!
I’d appreciate your advice. I have a React frontend with a NodeJS Express backend. The backend makes REST API calls to our Jira Cloud instance using an Atlassian OAuth 2.0 Bearer Token.
I’ve configured everything according to the OAuth 2.0 3LO docs.
I am able to authenticate successfully and I can make GET fetches from the NodeJS server and feed that data back to my React client.
I have configured my scopes to include Classic Scope: write:jira-work as noted in the Create Issue Cloud API doc.
When I authenticate it shows me that my scope includes the ability to update Jira work:
I am able to send the same Create Issue command successfully from the command line using Basic Auth, confirming that the request body is clean.
However, any attempt to POST using OAuth 2.0 and a Bearer Token responds with the error message ‘OAuth 2.0 is not enabled for method: POST /issue’.
Here is the app.post from my NodeJS Express server:
app.post("/issue", async (req, res) => {
const api = "/issue";
const payload = req.query;
const token = payload.token;
const projectKey = payload.projectKey;
const emails = payload.emails;
const body = "Project Key: " + projectKey + "\n\nEmails:\n" + emails;
console.log("body:");
console.log(body);
let url = JIRA_API_BASE_URL + JIRA_CLOUD_ID + api;
let headers = {
Authorization: "Bearer " + token,
Accept: "application/json",
"Content-Type": "application/json",
};
let bodyData = {
fields: {
summary: "ADD Users to " + projectKey,
issuetype: { id: ADMIN_INTAKE_ISSUE_TYPE },
project: { id: ADMIN_PROJECT_ID },
description: {
type: "doc",
version: 1,
content: [
{
type: "paragraph",
content: [{ type: "text", text: body }],
},
],
},
},
update: {},
};
const data = await fetch(url, {
method: "POST",
headers: headers,
body: JSON.stringify(bodyData),
});
let output;
try {
output = await data.json();
} catch (e) {
console.error(e);
} finally {
res.send(output);
}
});