0

I am creating a simple Node application that posts a new Activity using the Forge Design Automation API. The activity is not supposed to do anything. This is just a test and I plan to delete the Activity right away. When I run this, I get an internal server error. What am I doing wrong?

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();

And here's what I get from logging the error...

enter image description here

Not much there, so I'm at a loss.

  • What exactly was the error? Can’t see any apparent syntax/API-level errors in your code. Pls append any error messages available. – Bryan Huang Jan 09 '19 at 07:37
  • I wasn’t expecting our SDK/APIs to return so little when an error is thrown but you step in [here](https://github.com/Autodesk-Forge/forge-api-nodejs-client/blob/5bf1470155d4bc98985db38bcbdd73fe547d14bd/src/ApiClient.js#L385) with your favourite debugger and check on the error details, if any. But I guess the endpoints were complaining about the lack of required parameters - see [here](https://forge.autodesk.com/en/docs/design-automation/v2/reference/http/Activities-POST/) for a list of them and you can see `appPackages` and `parameters` are both required – Bryan Huang Jan 14 '19 at 10:22

0 Answers0