Unauthorized access 401

I am trying to make a REST API call from my Rocketchat server to Jira server, however I get hit with the 401 error. I’ve read multiple documents regarding this such as use API token instead of username:password, grants permissions and etc but for some reason it is just not working.

This is my TypeScript code:

import {
} from '@rocket.chat/apps-engine/definition/accessors';
import fetch from 'node-fetch';
import {
} from '@rocket.chat/apps-engine/definition/slashcommands';

 export class n implements ISlashCommand {
    public command = 'n';
    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": "TEST"},"summary": "TEST the API","description": "testing API","issuetype": {"name": "Bug"}}}
      const token = 'email:api_token'
      const encoded = Buffer.from(token).toString('base64');
      const response = await fetch('http://localhost:8080/rest/api/2/issue/', {
        method: 'post',
        body: JSON.stringify(supply),
        headers: {'Content-Type': 'application/json',
                  'Authorization': 'Basic ' + encoded },
      const responseText = await response.text();

The string that has been converted to base64, returns 2 equal signs at the end of the string - so something like this aHVzc2Vpbi45LjAwQGhvdG1haWwuY29tOkFUQVRUM3hGZkdGMGpsNHd1SG== Is that normal? Thats the only thing I can think of which is possibly causing this 401 error.

Any help is appreciated - thanks

ok so I have removed the 2 equal signs at the end and this error does not occur no more, instead i get the following error, {"errorMessages":[],"errors":{"Summary":"Field 'Summary' cannot be set. It is not on the appropriate screen, or unknown.","Description":"Field 'Description' cannot be set. It is not on the appropriate screen, or unknown."}}