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 => {
});
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
Nothing it didn't worked
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
@Roberto Teresa the end poit should contain you instance URL. Something like : "https://XXXX.atlassian.net/jira/rest/api/3/issue/{issueIdOrKey}/attachments"
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.