| 99 | if (params?.visibility) payload.visibility = params.visibility |
| 100 | |
| 101 | const makeRequest = async (cloudId: string) => { |
| 102 | const commentUrl = `https://api.atlassian.com/ex/jira/${cloudId}/rest/api/3/issue/${params!.issueKey?.trim() ?? ''}/comment` |
| 103 | const commentResponse = await fetch(commentUrl, { |
| 104 | method: 'POST', |
| 105 | headers: { |
| 106 | Accept: 'application/json', |
| 107 | 'Content-Type': 'application/json', |
| 108 | Authorization: `Bearer ${params!.accessToken}`, |
| 109 | }, |
| 110 | body: JSON.stringify(payload), |
| 111 | }) |
| 112 | |
| 113 | if (!commentResponse.ok) { |
| 114 | let message = `Failed to add comment to Jira issue (${commentResponse.status})` |
| 115 | try { |
| 116 | const err = await commentResponse.json() |
| 117 | message = err?.errorMessages?.join(', ') || err?.message || message |
| 118 | } catch (_e) {} |
| 119 | throw new Error(message) |
| 120 | } |
| 121 | |
| 122 | return commentResponse.json() |
| 123 | } |
| 124 | |
| 125 | let data: any |
| 126 | |