0

我正在创建一个简单的节点应用程序,它使用 Forge 设计自动化 API 发布一个新的活动。该活动不应该做任何事情。这只是一个测试,我计划立即删除 Activity。当我运行它时,我得到一个内部服务器错误。我究竟做错了什么?

const config = require(`./utils/Config`);
const CLIENT_ID = config.forge.credentials.client_id;
const CLIENT_SECRET = config.forge.credentials.client_secret;
const autoRefresh = true;

const ForgeSDK = require(`forge-apis`);
const oAuth2TwoLegged = new ForgeSDK.AuthClientTwoLegged(CLIENT_ID, CLIENT_SECRET, [`code:all`], autoRefresh);
const ActivitiesApi = new ForgeSDK.ActivitiesApi();

const activityObject = {
  id: `TestActivity`,
  instruction: {
    CommandLineParameters: null,
    Script: ``
  },
  appPackages: [``],
  requiredEngineVersion: `20.1`,
  parameters: { InputParameters: [], OutputParameters: [] },
  allowedChildProcesses: [],
  version: 1,
  isPublic: true,
  theData: null,
  obj: null
};

const activity = new ForgeSDK.Activity(
  activityObject.id,
  activityObject.instruction,
  activityObject.appPackages,
  activityObject.requiredEngineVersion,
  activityObject.parameters,
  activityObject.allowedChildProcesses,
  activityObject.version,
  activityObject.isPublic,
  activityObject.theData,
  activityObject.obj
);

const main = async () => {
  try {
    await oAuth2TwoLegged.authenticate();
    createActivity();
  } catch (error) {
    console.log(error);
  }
}

const createActivity = async () => {
  try {
    await ActivitiesApi.createActivity(activity, oAuth2TwoLegged, oAuth2TwoLegged.getCredentials());    
  } catch (error) {
    console.log(`Creating the activity did not work!`);
    console.log(error);
  }
};


main();

这是我从记录错误中得到的...

在此处输入图像描述

那里不多,所以我很茫然。

4

0 回答 0