autodesk-forge / forge-api-nodejs-client Goto Github PK
View Code? Open in Web Editor NEWForge Node.js SDK: Provides Node.js SDK to help you easily integrate Forge REST APIs into the application
License: Apache License 2.0
Forge Node.js SDK: Provides Node.js SDK to help you easily integrate Forge REST APIs into the application
License: Apache License 2.0
I am little confused with the new Autodesk Forge NextGen initiative.. Does it mean that Forge API will be significantly refactored in the near future and is this package still actively maintained? According to this video it looks like there will be a new SDK with several packages like @adsk/forge-appfw-core etc.
Hi,
I'm trying to use oAuth2ThreeLegged.refreshToken
and oAuth2TwoLegged.refreshToken
to refresh the tokens but there seems to be problems with that.
oAuth2TwoLegged
doesn't even find a refreshToken
function.
And oAuth2ThreeLegged
manages to refresh once, but afterwards I get:
(node:5936) UnhandledPromiseRejectionWarning: Unhandled promise rejection (rejection id: 1): [object Object]
Is there a limit on update requests per minute? If so how long should I wait before updating?
That API is used to delete or rename a folder.
Hi
I need is to get room/area objects with the hierarchy of linked objects from the revit model. Right now I am using this project as a start point. Unfortunately, the room information in lost. As far as I understand, it is removed during the translation process. There are some workarounds like this one, but it doesn't seem to work for our case. Is there any straightforward way to retrieve room information from rvt in Forge?
I'm trying to use GetFolderContents api as per below (in C#):
var folderItems = foldersApi.GetFolderContents(projectId, folderId, filterType: new List<string>() { "items" }, pageLimit: 1000);
but I'm getting below error:
Error calling GetFolderContents: { "jsonapi": { "version": "1.0" }, "errors": [{ "id": "6ffd7c96-0c44-4223-8fa2-713bd02a548a", "status": "400", "code": "BAD_INPUT", "title": "One or more input values in the request were bad", "detail": "The limit value is invalid." } ] }
I am using v1.5 of the Forge dll from nuget btw
1-) getBuckets doesn't work without a callback function(err). So, I suggest to add this callback to the sample.
2-) getBuckets need "buckets: read". The sample on this page suggest to use the "token that were obtained from the previous step". I suggest to add a comment "notice that you need do add a buckets: read permission"
In the API https://github.com/Autodesk-Forge/forge-api-nodejs-client/blob/master/docs/FoldersApi.md#postFolder, the definition of type CreateFolder is not actually defined, check https://github.com/Autodesk-Forge/forge-api-nodejs-client/blob/master/docs/CreateFolder.md
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.
Hi,
Updated the SDK to the latest revision, now no longer able to submit a job for translation.
it gives an error when building a job object for translation function call:
job = new ForgeAPI.JobPayload {
input: {
urn: urn
},
output: {
formats: [ {type: "svf", views: ["2d","3d"]} ]
}
}
JobPayload
is using JobPayloadInput
and JobPayloadOutput
which use a method called ApiClient.convertToType
that no longer exists.
Can you please advice what to do?
Forge docs says 'Range'
the node-js client use 'range'
to keep backward compatibility, we could use:
var headerParams = {
'Range': opts['range'] || opts['Range'],
ObjectsApi.js line #283, #430
Hi, I have a trouble with https://developer.api.autodesk.com/project/v1/hubs/project/v1/hubs
Right now I'm testing this endpoint in Postman with the following headers:
Content-Type: application/vnd.api+json
Accept: application/json, application/vnd.api+json
Authorization: Bearer {{AccessToken}}
Unfortunately, I've got an error with 403 status code, when sending this request:
{
"jsonapi": {
"version": "1.0"
},
"errors": [
{
"status": "403",
"code": "BIM360DM_ERROR",
"title": "Unable to get hubs from BIM360DM US.",
"detail": "You don't have permission to access this API"
},
{
"status": "403",
"code": "BIM360DM_ERROR",
"title": "Unable to get hubs from BIM360DM EMEA.",
"detail": "You don't have permission to access this API"
}
]
}
Other API calls ( https://developer.api.autodesk.com/modelderivative/v2/designdata/formats, for instance, are working properly)
What can be the reason for this?
OAuth2ThreeLegged.generateAuthUrl does not allow a state to be added to the generated url.
Described here https://developer.autodesk.com/en/docs/oauth/v2/reference/http/authorize-GET/
Hi dear team,
The postFolder
method of FoldersApi does not have a proper definition for pathParams
which should include project_id
.
https://github.com/Autodesk-Forge/forge-api-nodejs-client/blob/master/src/api/FoldersApi.js#L329 should be something like this:
var pathParams = { project_id: body.projectID };
Also the documentation for:
https://github.com/Autodesk-Forge/forge-api-nodejs-client/blob/master/docs/CreateFolder.md
...is missing.
I read #34.
It said it's working, but it's been a long time till now without any d.ts file or typescript rewrite.
As there has been no reply to the last question about progess, hereby I open a new issue.
Is there any specific plan?
I'm trying to take a set of file stored in one bucket and copy them to another (one is transient and one is temporary - the files are to be stored for a longer period of time). I'm using the NodeJS ForgeSDK, using getObject to download the file, then uploadObject to put it in the second bucket. This seems to work fine for most of the files I'm moving, but fails when I try to use it on a JSON file.
I've tried converting the JSON both to a buffer and to a string before the uploadObject call, both fail giving a gateway timeout error.
Trying to upload an object
**** Uploading file. bucket:forge_sample_c6eaxriflqyzvmirmt306hsmawehv9ig filePath:D:/Project/bca-rvt/CCDC_HP_B4_ST_TYPICAL.rvt
D:/Project/bca-rvt/CCDC_HP_B4_ST_TYPICAL.rvt
buckets > [object Object]
{ statusCode: 401, statusMessage: 'Unauthorized' }
**** Upload file response: undefined
fs.createReadStream(filePath).pipe(`
request.put({
url:'https://developer.api.autodesk.com/oss/v2/buckets/'+bucketKey+'/objects/'+fileName,
headers:{
'Authorization':' Bearer ' + oAuth2TwoLegged.access_token
}
},function(err,response,body){
if(err) {
reject(null);
}
resolve(body);
}));
after switching from request
to superagent
in 0.9.0 release getObject stopped working, the response.body is empty ({}
), no any errors.
Most likely it affects only objects larger than a certain size (our models are usually bigger than 500K).
Anyway, the solution is to buffer the response. I've made a PR #82
Please review and accept.
Hi,
I'm currently implementing the partial uploads of large files to the Forge platform, and encountered an issue which gives { statusCode: 400, statusMessage: 'Bad Request' }
. Digged the codebase and found that header parameters that are prepared in ObjectsApi.uploadChunk
:
var headerParams = {
'Content-Length': contentLength,
'Content-Range': contentRange,
'Content-Disposition': opts['contentDisposition'],
'If-Match': opts['ifMatch'],
'Session-Id': sessionId
};
are sent to ApiClient.callApi
, but those parameters are not actually added at all to the request, hence causing issues.
Can you please clarify this?
this endpoint is missing in the SDK
Hi there,
Just a heads up that there's a somewhat offputting moment in the (would be) very helpful example on the main readme page for this repo: the required scopes for the example are not in place. Further, the example fails silently. In order to see the error at all, I had to take the access token, log it, then do the getBuckets request via curl in order to see this:
Token does not have the privilege for this request.
That made it clear that I needed to find a page about scopes, which turned out to be this one:
https://developer.autodesk.com/en/docs/oauth/v2/overview/scopes/
So I could then figure out to add 'bucket:read'
to this:
var oAuth2TwoLegged = new ForgeSDK.AuthClientTwoLegged(CLIENT_ID, CLIENT_SECRET, [
'data:read',
'data:write'
], autoRefresh);
Updating the docs would be very much appreciated by future devs, I'm sure. Thanks!
Hello Forge-Team,
I'd like to ask you to add TypeScript definitions for the NodeJS client.
For us, TypeScript is crucial in our big projects, and as we want to make heavy use of Forge, we'd highly appreciate having TypeScript definitions for your API.
Regards,
Michael
It says in the readme to "run the following code" for the 2-legged and 3-legged tokens, but where this code is supposed to be placed?
I couldn't even find in any of the files 'CLIENT_ID'.
Edit:
So I placed the 2/3-legged code in a file and ran it with node, in the 3-legged oAuth2ThreeLegged.generateAuthUrl();
doesn't return authorizationCode
in the url, and if I try to navigate to that url, I get:
{"developerMessage":"The required parameter(s) redirect_uri not present in the request","userMessage":"","errorCode":"AUTH-008","more info":"http://developer.api.autodesk.com/documentation/v1/errors/AUTH-008"}
Hello - recently it was announced that certain data management API calls would be deprecated in favor of direct uploads and downloads from the underlying AWS S3 bucket. We make use of a couple of methods in the ObjectsApi
and I'm wondering if we'll need to plan for these changes or if this package will be handling that automatically.
For example, we use ObjectsApi.uploadChunk
for resumable uploads, which calls this soon-to-be-deprecated method. Will uploadChunk
be updated under the hood to call the new direct-to-s3 endpoint?
Hi,
When installing through NPM there is a warning about the deprecated module:
npm WARN deprecated [email protected]: use uuid module instead
Many thanks
Looks like there's something wrong with the getDerivativeManifest()
function. When I use it like this:
DerivativesApi.getDerivativeManifest(designUrn, derivUrn, {}, oAuth2TwoLegged, credentials)
.then(function(done){
console.log(done);
})
.catch(function(err){
console.log(err);
})
I always get this:
{ statusCode: 400, statusMessage: 'Bad Request' }
But when I instead log out my access token and urn's into a formatted curl request, that curl request works just fine:
console.log("curl -X 'GET' -H 'Authorization: Bearer "+credentials.access_token+"' -v 'https://developer.api.autodesk.com/modelderivative/v2/designdata/"+designUrn+"/manifest/"+derivUrn+"'");
That gives me a curl command that I can just run (**'d out some sensitive parts):
$ curl -X 'GET' -H 'Authorization: Bearer v6MLmO8mIc8UPI*************' -v 'https://developer.api.autodesk.com/modelderivative/v2/designdata/dXJuOmFkc2sub2JqZWN0czpvcy5vYmplY3Q6aW5zdHJ1Y3RhYmxlcy1mb3JnZS1kZXYt*********/manifest/urn%3Aadsk.viewing%3Afs.file%3AdX**************JnZS1kZXYtYnVja2V0L3Rlc3Quc3Rs%2Foutput%2F1%2Ftest.svf.png01_thumb_100x100.png'
... and it spits out data:
?PNG
IHDRdp?Td??IDATx^?]il]?u??7?O\?MK?TY?#5??ڍ]'?? u??hS(? E?(Z???ڢ@k???hDZ?cɑ?X?eS?(??HJ??g???3?Σ???A?{gΜ????v/C/??5??"????w?չ??Q????Z??ޫ?
BGo?~J?????g"??Q?ՠ?&????R?}tJQS1???I[t???tKQ*8
Just FYI, there's a bug that deserves a failing unit test.
NestJS is getting more and more popular. Although there is a DefinitelyType of forge api, it would be better if AutoDesk could provide a proper port from ExpressJS to NestJS.
Can you show a concrete example using autoRefresh = true? Do my client code needs to pass a callback or can I assume calling OAuth2TwoLegged.prototype.getCredentials
will always return a valid token? By looking at the implementation it seems to me autoRefresh is not doing anything ...
Hi all,
I think that there is no way to set the x-ads-content-sha1 header using this wrapper.
You can pass the If-Match parameter, but according to API documentation they are different
If-Match | When overwriting an object, use the latest SHA-1 hash to verify that you are overwriting the latest data.A SHA-1 hash is returned every time you upload or overwrite an object. If the SHA-1 hash in the header does not match the current SHA-1 hash stored for this object in OSS, the request fails (status code 412).
x-ads-content-sha1 | A SHA-1 checksum of the object represented as a hexadecimal string.If the SHA-1 hash in the header does not match the SHA-1 hash computed by the server for the uploaded object, the request fails (status code 400).
Thanks.
createBucket
request sya only 400:badRequestFor our staging environment, the basePath needs to be set to https://developer-stg.api.autodesk.com
. I solve that now by doing something like:
const apiClient = new ForgeSDK.ApiClient()
apiClient.basePath = "https://developer-stg.api.autodesk.com"
...
const oAuth2TwoLegged = new ForgeSDK.AuthClientTwoLegged(...)
oAuth2TwoLegged.basePath = "https://developer-stg.api.autodesk.com"
Is it possible to make this settable by providing the basePath to the constructor (options object), or something else?
Hi, i was trying the api's in one of my angular app, i was using 2 legged authentication and i end up with cors error, is there any other config i need to do before i try these api.
Failed to load https://developer.api.autodesk.com/authentication/v1/authenticate: No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'https://seligentinfra.com' is therefore not allowed access. If an opaque response serves your needs, set the request's mode to 'no-cors' to fetch the resource with CORS disabled.
Thanks
if you use
ModelDerivative.deleteManifest (content.urn, forgeToken.RW, forgeToken.RW.getCredentials ())
or
ObjectsApi.deleteObject (bucket, desc.objectKey, forgeToken.RW, forgeToken.RW.getCredentials ())
you get an exception wth the following message
Error:TypeError: requestParams.form is not a function
https://github.com/Autodesk-Forge/forge-api-nodejs-client/blob/master/src/ApiClient.js#L342
< requestParams.form(this.normalizeParams(formParams));
should be
requestParams.form =this.normalizeParams(formParams);
Hello,
The promise return seem to not be compatible with async/await.
Here is my code :
var oAuth2TwoLegged = new ForgeSDK.AuthClientTwoLegged(secret.clientId, secret.clientSecret, forgeScope, true);
await oAuth2TwoLegged.authenticate();
// other code here
The proccess is finish without any error and without any response.
The rest of the code is not excecuted.
Howdy all,
Software team lead for Bechtel Center at Purdue here.
Problem: I was getting a "BAD_INPUT" error by utilizing the postItem() function.
Description: Consulted the api docs, and found this note on the data.attributes.displayName field:
Note that for A360 projects, this field is required.
Note that for BIM 360 projects, this field is reserved for future releases and should not be used. Use included[0].attributes.name for the file name.
The current version of postItem function utilizes the "CreateStorageDataAttributes" model within a "createItemData". A TypeScript compile error results from using "displayName" instead of "name" with this model, but using "name" results in a 400 error as shown below (1). By implementing a workaround and modifying by types file I could get it working (2).
It is quite possible I missed something, and I simply used something incorrectly.
Thank you for your work on this module, have a great day.
Supporting Docs:
1:
API ERROR CODE: 400
MESSAGE: BadRequest
BODY: {
jsonapi: { version: '1.0' },
errors: [
{
id: REDACTED,
status: '400',
code: 'BAD_INPUT',
title: 'One or more input values in the request were bad',
detail: 'Display name not found, should be in resource: "data.attributes.displayName".'
}
]
}
2:
CODE: 201
BODY: {
jsonapi: { version: '1.0' },
links: {
self: {
href: REDACTED
}
},
data: {
type: 'items',
id: REDACTED,
attributes: {
displayName: 'foo.txt',
createTime: '2022-01-27T19:55:39.0000000Z',
createUserId: REDACTED,
createUserName: 'Gavin',
lastModifiedTime: '2022-01-27T19:55:39.0000000Z',
lastModifiedUserId: REDACTED,
lastModifiedUserName: 'Gavin',
hidden: false,
reserved: false,
extension: [Object]
},
links: { self: [Object] },
relationships: {
tip: [Object],
versions: [Object],
parent: [Object],
refs: [Object],
links: [Object]
}
},
included: [
{
type: 'versions',
id: REDACTED,
attributes: [Object],
links: [Object],
relationships: [Object]
}
]
}
The following code will produce non white space encoded characters
var scope =[ 'data:read', 'data:write', 'data:create', 'data:search', 'account:read', 'user-profile:read', 'viewables:read' ] ;
var oauth =new ForgeSDK.AuthClientThreeLegged (client_id, client_secret, redirect_uri, scope, false) ;
console.log (oauth.generateAuthUrl ()) ;
https://developer.api.autodesk.com/authentication/v1/authorize?response_type=code&client_id=XXX&redirect_uri=http://localhost:3000/callback&scope=data:read data:write data:create data:search account:read user-profile:read viewables:read&state=undefined
When using checkPermission method on Commands API class, regardless of the input it always returns status code 404:
{
"developerMessage": "The requested resource does not exist.",
"moreInfo": "https://forge.autodesk.com/en/docs/oauth/v2/developers_guide/error_handling/",
"errorCode": "org.mozilla.javascript.Undefined@0"
}
It seems like the internal method _commandsApiCal
is using the request method GET
and according to the documentation it should be POST
forge-api-nodejs-client/src/api/CommandsApi.js
Lines 191 to 195 in 33b121b
Documentation here:
https://forge.autodesk.com/en/docs/data/v2/reference/http/CheckPermission/
I can successfully use the check permission command when calling the API externally.
Best Regards,
/Karl
I see no AccountAdmin
class or accounts
path in sources. Is there any plans to implement something like AccountAdmin
class (create new project, create new company and activate service which are described in this documentation)
The current version of request has security issues with hawk, http-signature, qs and more that are all updated in 2.82.0.
Basically, just have to up the version and everything should work fine.
Hey,
I'm trying to add custom headers to requests made to forge API. I noticed that the ApiClient attribute defaultHeaders is not being used within the api client, meaning even if we create a custom client with required headers, they never get applied to the requests made against forge API. I'd guess this was a bug with SwaggerCode gen.
Any chance the ApiClient could be modified to actually apply the default headers that are set?
I.e. normally swagger autogen would generate this line: request.set(this.defaultHeaders).set(this.normalizeParams(headerParams));
However in the ApiClient here, the default headers are never actually applied.
I'd make a PR but I'd assume regen through swagger would be approved approach...
Tom
When calling this DerivativesApi.getHierarchy(urn, guid, token, callback);
it gives me the following error
(node:16284) UnhandledPromiseRejectionWarning: Unhandled promise rejection (rejection id: 1): [object Object]
https://www.npmjs.com/package/forge-apis is different from https://github.com/Autodesk-Forge/forge-api-nodejs-client/blob/master/package.json#L3. I pulled the tarball from npm and it doesn't look like the code up there is different from what's in the repo.
This was a little confusing to me and I want to make sure there isn't anything missing from the repo.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.