Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in
Celebration

Earn badges and make progress

You're on your way to the next level! Join the Kudos program to earn points and save your progress.

Deleted user Avatar
Deleted user

Level 1: Seed

25 / 150 points

Next: Root

Avatar

1 badge earned

Collect

Participate in fun challenges

Challenges come and go, but your rewards stay with you. Do more to earn more!

Challenges
Coins

Gift kudos to your peers

What goes around comes around! Share the love by gifting kudos to your peers.

Recognition
Ribbon

Rise up in the ranks

Keep earning points to reach the top of the leaderboard. It resets every quarter so you always have a chance!

Leaderboard

Problem creating attachment in issue via API

Roberto Teresa
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!
Oct 20, 2023

Im trying to create an attachment in Jira via API using this code but Im getting error 404 not found

 

   const endpoint = `/rest/api/2/issue/${jiraIssue.key}/attachments`;

    const FormData = require('form-data');

    cy.fixture('../../'+filePath, 'binary').then((fileBin) => {

      const blob = Cypress.Blob.binaryStringToBlob(fileBin);

      const formData = new FormData();

      formData.append('file', blob, { filename: 'issue.feature' });

      for (let [key, value] of formData.entries()) {

        console.log(key, value);

      }

      cy.request({

        method: 'POST',

        url: `${this.apiUrl}${endpoint}`, // baseUrl is prepend to URL

        body: formData,

        headers: {

          Authorization: `Basic ${this.apiKey}`,

          'Content-Type': 'text/plain',

          'X-Atlassian-Token': 'no-check',

        }

      }).then(response => {

         if (response.status === 204) {
          console.log(`Response: ${response.status} ${response.statusText}`);
        }


      });

1 answer

0 votes
Fabio Racobaldo _Herzum_
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
Oct 20, 2023

Hi @Roberto Teresa and welcome,

please take a look here https://developer.atlassian.com/cloud/jira/platform/rest/v3/api-group-issue-attachments/#api-rest-api-3-issue-issueidorkey-attachments-post

it seems that you are using version 2 and not version 3.

Hope this helps,

Fabio

Roberto Teresa
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!
Oct 20, 2023

Nothing it didn't worked

Fabio Racobaldo _Herzum_
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
Oct 20, 2023

@Roberto Teresa the end poit should contain you instance URL. Something like : "https://XXXX.atlassian.net/jira/rest/api/3/issue/{issueIdOrKey}/attachments"

Suggest an answer

Log in or Sign up to answer