I have looked at countless JIRA API docs and I still have no luck with it all. I get a 401 error trying to make an API call between my rocketchat server and jira server.
The credentials are 100% correct and I have set all the permission to "Anyone on the web" which means it is nothing to do with incorrect credentials right?
import {
IHttp,
IModify,
IRead,
} from '@rocket.chat/apps-engine/definition/accessors';
import fetch from 'node-fetch';
import {
ISlashCommand,
SlashCommandContext,
} from '@rocket.chat/apps-engine/definition/slashcommands';
export class n implements ISlashCommand {
public command = 'bb';
public i18nParamsExample = '';
public i18nDescription = '';
public providesPreview = false;
public async executor(context: SlashCommandContext, read: IRead, modify: IModify, http: IHttp): Promise<void> {
const supply = {"fields": {"project": {"key": "HUS"}, "summary" : "LOL", "issuetype": {"name": "Task"}}}
const response = await fetch('http://localhost:8080/rest/api/2/issue/', {
method: 'post',
body: JSON.stringify(supply),
headers: {'Content-Type': 'application/json',
'Authorization': `Basic ${Buffer.from('email:api_token').toString('base64')}`},
});
const responseText = await response.text();
};
};
The auth section was taken from https://developer.atlassian.com/cloud/jira/platform/rest/v3/api-group-issue-types/#api-rest-api-3-issuetype-post
Please can someone shed some light on this, much apprechiated