mirror of
https://github.com/n8n-io/n8n.git
synced 2025-03-05 20:50:17 -08:00
🐛 Fix API version for Jira server (#1866)
This commit is contained in:
parent
28eb8ca166
commit
20be641e63
|
@ -731,6 +731,8 @@ export class Jira implements INodeType {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (resource === 'issueAttachment') {
|
if (resource === 'issueAttachment') {
|
||||||
|
const apiVersion = jiraVersion === 'server' ? '2' : '3' as string;
|
||||||
|
|
||||||
//https://developer.atlassian.com/cloud/jira/platform/rest/v3/api-group-issue-attachments/#api-rest-api-3-issue-issueidorkey-attachments-post
|
//https://developer.atlassian.com/cloud/jira/platform/rest/v3/api-group-issue-attachments/#api-rest-api-3-issue-issueidorkey-attachments-post
|
||||||
if (operation === 'add') {
|
if (operation === 'add') {
|
||||||
for (let i = 0; i < length; i++) {
|
for (let i = 0; i < length; i++) {
|
||||||
|
@ -751,7 +753,7 @@ export class Jira implements INodeType {
|
||||||
|
|
||||||
responseData = await jiraSoftwareCloudApiRequest.call(
|
responseData = await jiraSoftwareCloudApiRequest.call(
|
||||||
this,
|
this,
|
||||||
`/api/3/issue/${issueKey}/attachments`,
|
`/api/${apiVersion}/issue/${issueKey}/attachments`,
|
||||||
'POST',
|
'POST',
|
||||||
{},
|
{},
|
||||||
{},
|
{},
|
||||||
|
@ -774,7 +776,7 @@ export class Jira implements INodeType {
|
||||||
if (operation === 'remove') {
|
if (operation === 'remove') {
|
||||||
for (let i = 0; i < length; i++) {
|
for (let i = 0; i < length; i++) {
|
||||||
const attachmentId = this.getNodeParameter('attachmentId', i) as string;
|
const attachmentId = this.getNodeParameter('attachmentId', i) as string;
|
||||||
responseData = await jiraSoftwareCloudApiRequest.call(this, `/api/3/attachment/${attachmentId}`, 'DELETE', {}, qs);
|
responseData = await jiraSoftwareCloudApiRequest.call(this, `/api/${apiVersion}/attachment/${attachmentId}`, 'DELETE', {}, qs);
|
||||||
returnData.push({ success: true });
|
returnData.push({ success: true });
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -783,7 +785,7 @@ export class Jira implements INodeType {
|
||||||
const download = this.getNodeParameter('download', 0) as boolean;
|
const download = this.getNodeParameter('download', 0) as boolean;
|
||||||
for (let i = 0; i < length; i++) {
|
for (let i = 0; i < length; i++) {
|
||||||
const attachmentId = this.getNodeParameter('attachmentId', i) as string;
|
const attachmentId = this.getNodeParameter('attachmentId', i) as string;
|
||||||
responseData = await jiraSoftwareCloudApiRequest.call(this, `/api/3/attachment/${attachmentId}`, 'GET', {}, qs);
|
responseData = await jiraSoftwareCloudApiRequest.call(this, `/api/${apiVersion}/attachment/${attachmentId}`, 'GET', {}, qs);
|
||||||
returnData.push({ json: responseData });
|
returnData.push({ json: responseData });
|
||||||
}
|
}
|
||||||
if (download) {
|
if (download) {
|
||||||
|
@ -825,6 +827,8 @@ export class Jira implements INodeType {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (resource === 'issueComment') {
|
if (resource === 'issueComment') {
|
||||||
|
const apiVersion = jiraVersion === 'server' ? '2' : '3' as string;
|
||||||
|
|
||||||
//https://developer.atlassian.com/cloud/jira/platform/rest/v3/api-group-issue-comments/#api-rest-api-3-issue-issueidorkey-comment-post
|
//https://developer.atlassian.com/cloud/jira/platform/rest/v3/api-group-issue-comments/#api-rest-api-3-issue-issueidorkey-comment-post
|
||||||
if (operation === 'add') {
|
if (operation === 'add') {
|
||||||
for (let i = 0; i < length; i++) {
|
for (let i = 0; i < length; i++) {
|
||||||
|
@ -840,23 +844,27 @@ export class Jira implements INodeType {
|
||||||
Object.assign(body, options);
|
Object.assign(body, options);
|
||||||
if (jsonParameters === false) {
|
if (jsonParameters === false) {
|
||||||
const comment = this.getNodeParameter('comment', i) as string;
|
const comment = this.getNodeParameter('comment', i) as string;
|
||||||
Object.assign(body, {
|
if (jiraVersion === 'server') {
|
||||||
body: {
|
Object.assign(body, { body: comment });
|
||||||
type: 'doc',
|
} else {
|
||||||
version: 1,
|
Object.assign(body, {
|
||||||
content: [
|
body: {
|
||||||
{
|
type: 'doc',
|
||||||
type: 'paragraph',
|
version: 1,
|
||||||
content: [
|
content: [
|
||||||
{
|
{
|
||||||
type: 'text',
|
type: 'paragraph',
|
||||||
text: comment,
|
content: [
|
||||||
},
|
{
|
||||||
],
|
type: 'text',
|
||||||
},
|
text: comment,
|
||||||
],
|
},
|
||||||
},
|
],
|
||||||
});
|
},
|
||||||
|
],
|
||||||
|
},
|
||||||
|
});
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
const commentJson = this.getNodeParameter('commentJson', i) as string;
|
const commentJson = this.getNodeParameter('commentJson', i) as string;
|
||||||
const json = validateJSON(commentJson);
|
const json = validateJSON(commentJson);
|
||||||
|
@ -867,7 +875,7 @@ export class Jira implements INodeType {
|
||||||
Object.assign(body, { body: json });
|
Object.assign(body, { body: json });
|
||||||
}
|
}
|
||||||
|
|
||||||
responseData = await jiraSoftwareCloudApiRequest.call(this, `/api/3/issue/${issueKey}/comment`, 'POST', body, qs);
|
responseData = await jiraSoftwareCloudApiRequest.call(this, `/api/${apiVersion}/issue/${issueKey}/comment`, 'POST', body, qs);
|
||||||
returnData.push(responseData);
|
returnData.push(responseData);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -878,7 +886,7 @@ export class Jira implements INodeType {
|
||||||
const commentId = this.getNodeParameter('commentId', i) as string;
|
const commentId = this.getNodeParameter('commentId', i) as string;
|
||||||
const options = this.getNodeParameter('options', i) as IDataObject;
|
const options = this.getNodeParameter('options', i) as IDataObject;
|
||||||
Object.assign(qs, options);
|
Object.assign(qs, options);
|
||||||
responseData = await jiraSoftwareCloudApiRequest.call(this, `/api/3/issue/${issueKey}/comment/${commentId}`, 'GET', {}, qs);
|
responseData = await jiraSoftwareCloudApiRequest.call(this, `/api/${apiVersion}/issue/${issueKey}/comment/${commentId}`, 'GET', {}, qs);
|
||||||
returnData.push(responseData);
|
returnData.push(responseData);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -891,11 +899,11 @@ export class Jira implements INodeType {
|
||||||
const body: IDataObject = {};
|
const body: IDataObject = {};
|
||||||
Object.assign(qs, options);
|
Object.assign(qs, options);
|
||||||
if (returnAll) {
|
if (returnAll) {
|
||||||
responseData = await jiraSoftwareCloudApiRequestAllItems.call(this, 'comments', `/api/3/issue/${issueKey}/comment`, 'GET', body, qs);
|
responseData = await jiraSoftwareCloudApiRequestAllItems.call(this, 'comments', `/api/${apiVersion}/issue/${issueKey}/comment`, 'GET', body, qs);
|
||||||
} else {
|
} else {
|
||||||
const limit = this.getNodeParameter('limit', i) as number;
|
const limit = this.getNodeParameter('limit', i) as number;
|
||||||
body.maxResults = limit;
|
body.maxResults = limit;
|
||||||
responseData = await jiraSoftwareCloudApiRequest.call(this, `/api/3/issue/${issueKey}/comment`, 'GET', body, qs);
|
responseData = await jiraSoftwareCloudApiRequest.call(this, `/api/${apiVersion}/issue/${issueKey}/comment`, 'GET', body, qs);
|
||||||
responseData = responseData.comments;
|
responseData = responseData.comments;
|
||||||
}
|
}
|
||||||
returnData.push.apply(returnData, responseData);
|
returnData.push.apply(returnData, responseData);
|
||||||
|
@ -906,7 +914,7 @@ export class Jira implements INodeType {
|
||||||
for (let i = 0; i < length; i++) {
|
for (let i = 0; i < length; i++) {
|
||||||
const issueKey = this.getNodeParameter('issueKey', i) as string;
|
const issueKey = this.getNodeParameter('issueKey', i) as string;
|
||||||
const commentId = this.getNodeParameter('commentId', i) as string;
|
const commentId = this.getNodeParameter('commentId', i) as string;
|
||||||
responseData = await jiraSoftwareCloudApiRequest.call(this, `/api/3/issue/${issueKey}/comment/${commentId}`, 'DELETE', {}, qs);
|
responseData = await jiraSoftwareCloudApiRequest.call(this, `/api/${apiVersion}/issue/${issueKey}/comment/${commentId}`, 'DELETE', {}, qs);
|
||||||
returnData.push({ success: true });
|
returnData.push({ success: true });
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -925,23 +933,27 @@ export class Jira implements INodeType {
|
||||||
Object.assign(qs, options);
|
Object.assign(qs, options);
|
||||||
if (jsonParameters === false) {
|
if (jsonParameters === false) {
|
||||||
const comment = this.getNodeParameter('comment', i) as string;
|
const comment = this.getNodeParameter('comment', i) as string;
|
||||||
Object.assign(body, {
|
if (jiraVersion === 'server') {
|
||||||
body: {
|
Object.assign(body, { body: comment });
|
||||||
type: 'doc',
|
} else {
|
||||||
version: 1,
|
Object.assign(body, {
|
||||||
content: [
|
body: {
|
||||||
{
|
type: 'doc',
|
||||||
type: 'paragraph',
|
version: 1,
|
||||||
content: [
|
content: [
|
||||||
{
|
{
|
||||||
type: 'text',
|
type: 'paragraph',
|
||||||
text: comment,
|
content: [
|
||||||
},
|
{
|
||||||
],
|
type: 'text',
|
||||||
},
|
text: comment,
|
||||||
],
|
},
|
||||||
},
|
],
|
||||||
});
|
},
|
||||||
|
],
|
||||||
|
},
|
||||||
|
});
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
const commentJson = this.getNodeParameter('commentJson', i) as string;
|
const commentJson = this.getNodeParameter('commentJson', i) as string;
|
||||||
const json = validateJSON(commentJson);
|
const json = validateJSON(commentJson);
|
||||||
|
@ -951,13 +963,15 @@ export class Jira implements INodeType {
|
||||||
|
|
||||||
Object.assign(body, { body: json });
|
Object.assign(body, { body: json });
|
||||||
}
|
}
|
||||||
responseData = await jiraSoftwareCloudApiRequest.call(this, `/api/3/issue/${issueKey}/comment/${commentId}`, 'PUT', body, qs);
|
responseData = await jiraSoftwareCloudApiRequest.call(this, `/api/${apiVersion}/issue/${issueKey}/comment/${commentId}`, 'PUT', body, qs);
|
||||||
returnData.push(responseData);
|
returnData.push(responseData);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (resource === 'user') {
|
if (resource === 'user') {
|
||||||
|
const apiVersion = jiraVersion === 'server' ? '2' : '3' as string;
|
||||||
|
|
||||||
if (operation === 'create') {
|
if (operation === 'create') {
|
||||||
// https://developer.atlassian.com/cloud/jira/platform/rest/v3/api-group-users/#api-rest-api-3-user-post
|
// https://developer.atlassian.com/cloud/jira/platform/rest/v3/api-group-users/#api-rest-api-3-user-post
|
||||||
for (let i = 0; i < length; i++) {
|
for (let i = 0; i < length; i++) {
|
||||||
|
@ -971,14 +985,14 @@ export class Jira implements INodeType {
|
||||||
|
|
||||||
Object.assign(body, additionalFields);
|
Object.assign(body, additionalFields);
|
||||||
|
|
||||||
responseData = await jiraSoftwareCloudApiRequest.call(this, '/api/3/user', 'POST', body, {});
|
responseData = await jiraSoftwareCloudApiRequest.call(this, `/api/${apiVersion}/user`, 'POST', body, {});
|
||||||
returnData.push(responseData);
|
returnData.push(responseData);
|
||||||
}
|
}
|
||||||
} else if (operation === 'delete') {
|
} else if (operation === 'delete') {
|
||||||
// https://developer.atlassian.com/cloud/jira/platform/rest/v3/api-group-users/#api-rest-api-3-user-delete
|
// https://developer.atlassian.com/cloud/jira/platform/rest/v3/api-group-users/#api-rest-api-3-user-delete
|
||||||
for (let i = 0; i < length; i++) {
|
for (let i = 0; i < length; i++) {
|
||||||
qs.accountId = this.getNodeParameter('accountId', i);
|
qs.accountId = this.getNodeParameter('accountId', i);
|
||||||
responseData = await jiraSoftwareCloudApiRequest.call(this, '/api/3/user', 'DELETE', {}, qs);
|
responseData = await jiraSoftwareCloudApiRequest.call(this, `/api/${apiVersion}/user`, 'DELETE', {}, qs);
|
||||||
returnData.push({ success: true });
|
returnData.push({ success: true });
|
||||||
}
|
}
|
||||||
} else if (operation === 'get') {
|
} else if (operation === 'get') {
|
||||||
|
@ -992,7 +1006,7 @@ export class Jira implements INodeType {
|
||||||
qs.expand = expand.join(',');
|
qs.expand = expand.join(',');
|
||||||
}
|
}
|
||||||
|
|
||||||
responseData = await jiraSoftwareCloudApiRequest.call(this, '/api/3/user', 'GET', {}, qs);
|
responseData = await jiraSoftwareCloudApiRequest.call(this, `/api/${apiVersion}/user`, 'GET', {}, qs);
|
||||||
returnData.push(responseData);
|
returnData.push(responseData);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue