I get an error which states that the fields 'summary' and 'description' cannot be set because it is either unknown or not in appropriate screen.
I have seen many topics relating to this issue and I most likely suspect it to be an issue with authorization because I have added both fields to my screen.
My code is:
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 = '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": "HUS"},"Summary": "TEST the API","Description": "testing API","issuetype": {"name": "Bug"}}}
const text = "username:password"
const encoded = Buffer.from(text, 'utf8').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();
};
};
Is this how you authorise a request with API or not?