Forums

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

Adding attachment with oAuth 2.0 return OAuth 2.0 is not enabled.

Gilgamesh Sumsum
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!
March 15, 2023

Hi All,

I am trying to add attachment as mention in the guide in nodeJs https://developer.atlassian.com/cloud/jira/platform/rest/v3/api-group-issue-attachments/#api-group-issue-attachments 

But I am getting OAuth 2.0 is not enabled.

Here is my code:

const rootPath = path.join(__dirname, 'attachmentsToAdd.txt');
const form = new FormData();
const stats = fs.statSync(rootPath);
const fileSizeInBytes = stats.size;
const fileStream = fs.createReadStream(rootPath, 'utf8');

form.append('file', fileStream, { knownLength: fileSizeInBytes });

const response = await axios.post(
`https://api.atlassian.com/ex/jira/${resourceId}/rest/api/3/10057/attachments`,
form,
{
headers: {
Accept: 'application/json',
'X-Atlassian-Token': 'no-check',
Authorization: `Bearer ${accessToken}`,
},
},
);

As mention in the guide this should work with oauth2 and I have the relevant scope.
What could be the issue here?

Thanks!

1 answer

0 votes
Moses Thomas
Community Champion
March 15, 2023

@Gilgamesh Sumsum  Most likely you are not using  the right access-token properly in your code,  see how to generate API token  https://support.atlassian.com/atlassian-account/docs/manage-api-tokens-for-your-atlassian-account/

Try and let me know

 

Kind regards,

Moses

Suggest an answer

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

Atlassian Community Events