Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Can't get the API functions to work #8

Closed
SelaOAL opened this issue Dec 19, 2016 · 1 comment
Closed

Can't get the API functions to work #8

SelaOAL opened this issue Dec 19, 2016 · 1 comment

Comments

@SelaOAL
Copy link

SelaOAL commented Dec 19, 2016

I'm getting many 'x' is not a function when trying to invoke the functions listed in the API docs here:

This is the file I used to test this:

var ForgeSDK = require('forge-apis');
var CLIENT_ID = 'myid...' , CLIENT_SECRET = 'mysecret...', REDIRECT_URL = 'http://localhost:3000';
var autoRefresh = true;
var oAuth2TwoLegged = new ForgeSDK.AuthClientTwoLegged(CLIENT_ID, CLIENT_SECRET, [
    'data:read',
    'data:write'
], autoRefresh);

var oAuth2ThreeLegged = new ForgeSDK.AuthClientThreeLegged(CLIENT_ID, CLIENT_SECRET, REDIRECT_URL, [
    'data:read',
    'data:write'
], autoRefresh);

var str2leg = 'saved credentials string';
var str3leg = 'other saved credentials string';

var TwoLeggedCredentials = JSON.parse(str2leg);
var ThreeLeggedCredentials = JSON.parse(str3leg);

console.log(ForgeSDK.BucketsApi.getBuckets(oAuth2TwoLegged, TwoLeggedCredentials));

And I got that getBuckets is not a function.

Then I tried to load that same file to a node shell and run the following commands to test more functions, nothing seemed to work.
I couldn't find any of the functions listed in the docs when I tried to explore the ForgeSDK object...

> console.log(Object.getOwnPropertyNames(ForgeSDK.Buckets));
[ 'length', 'name', 'prototype', 'constructFromObject' ]
undefined
> var x = new ForgeSDK.Buckets
undefined
> console.log(x);
exports { items: undefined, next: undefined }
undefined
> console.log(Object.getOwnPropertyNames(x));
[ 'items', 'next' ]
undefined
> console.log(Object.getOwnPropertyNames(x.items));
TypeError: Cannot convert undefined or null to object
> console.log(ForgeSDK.Buckets);
{ [Function: exports] constructFromObject: [Function: constructFromObject] }
undefined
> console.log(ForgeSDK.Buckets.items);
undefined
> ForgeSDK.AppPackagesApi.getUploadUrl()
TypeError: ForgeSDK.AppPackagesApi.getUploadUrl is not a function

I'm probably not doing it right, can you please give an example on how to use the api functions?

PS: of course I use the right id, secret and credentials.

@gregra81
Copy link
Contributor

@SelaO-AL - Check out the sample in the README file:
https://github.com/Autodesk-Forge/forge-api-nodejs-client#example-api-calls

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants