Download a Document with Autodesk API - autodesk-forge

I'm trying to download documents from BIM 360 Docs. If I want to download a file with the type "type": "items:autodesk.bim360:File" I just need to get the bucketID and objectID (/projects/<projectID>/items/<itemID>) and call buckets/<bucketID>/objects/<ObjectID>. (I used this tutorial)
But how do I download a file with the type "type": "items:autodesk.bim360:Document"?
First, I get the version of the document /projects/<projectID>/items/<itemID>/versions. After that I call projects/<ProjectID>/versions/<versionID>/downloadFormats but it returns an empty JSON. The call projects/<ProjectID>/versions/<versionID>/downloads returns a 400 Bad Input. Whats the right way to get the bucket & objectID from a "document"? The way from the tutorial doesn't work because there is no "storage" tag in the JSON (example).

For BIM 360 Project Folder items, follow the tutorial here to download document.
Basically you will need to obtain the URN of the document from the relationships.storage.data.id field via GET projects/:project_id/folders/:folder_id/contents.
For item type items:autodesk.bim360:Document, call GET projects/:project_id/versions/:version_id/relationships/refs to obtain the storage locations:
"storage": {
"meta": {
"link": {
"href": "/oss/v2/buckets/wipbucket/objects/urn:adsk.objects:os.object:wip.dm.prod%2F9f8bdc3f-e29c-4ada-ab7b-bb8dfa821163.pdf"
}
}
See doc here.

Related

Continue error trying to change Google cloud trigger with REST APIs

I'm trying to change a trigger using REST API, specifically https://cloud.google.com/build/docs/api/reference/rest/v1/projects.triggers/patch. Note that I'm able to use curl and list all the triggers. Also I tried to download the trigger in JSON using https://cloud.google.com/build/docs/api/reference/rest/v1/projects.triggers/get (which works perfectly) but when I tried to upload the same file the error is always:
{
"error": {
"code": 400,
"message": "exactly 1 build config required, got: 0",
"status": "INVALID_ARGUMENT"
}
}
if I try to upload an invalid Json correctly it gives error parsing JSON, so surely it's trying to parse using JSON format.
So I tried the same experiment using "Try it!" button on Google page which opens Google APIs explorer. Same results. The interface gave me a warning that some fields are only output so I tried also to remove these fields but I got the same error.
The file I'm trying to upload is (changed some strings to remove company name)
{
"description": "Push to any branch",
"github": {
"push": {
"branch": ".*"
},
"owner": "company",
"name": "repo-utils"
},
"tags": [
"github-default-push-trigger"
],
"name": "default-push-trigger-127"
}
I think I found the issue. Google API seems to require either build or filename to be passed to specify a way to build. On the other hand the web interface allows to insert an Autodetect option for the build which will try to look for either cloudbuild.yaml or Dockerfile in the root directory. If you specify Autodetect on the web interface the Json configuration won't have either build or filename so when you try to import back that configuration it will fail.
I tried to pass filename as empty string, the web interface shows a cloudbuild.yaml (which is present) but the execution of the trigger fails.
So it seems there's no way to insert a Autodetect mode trigger using the API.

Unable to get revit filemeta data or see revit model in 3d viewer for forge modelderivative API

We have been using the model derivative api endpoints to extact data from forge but are currently having issues extracting meta data when uploading specifically Revit files.
Our process goes:
Auth
Upload a model in chunks https://developer.api.autodesk.com/oss/v2/buckets/{bucketKey}/objects/{objectName}/resumable
Create upload job https://developer.api.autodesk.com/modelderivative/v2/designdata/job
Get translation the process https://developer.api.autodesk.com/modelderivative/v2/designdata/{encodedUrn}/manifest
Get the object from the forge https://developer.api.autodesk.com/modelderivative/v2/designdata/{encodedUrn}/metadata
Current we are we receive a 200 response from step 5 with and empty meta information so we cannot extract anything.
When we load the 3D viewer (versions 6.0 and 4.0) the viewer calls the https://developer.api.autodesk.com/derivativeservice/v2/manifest/
When
"messages": [
{
"type": "error",
"code": "Revit-UnsupportedFileType",
"message": "<message>The file is not a Revit file or is not a supported version.</message>"
},
{
"type": "error",
"message": "Possibly recoverable warning exit code from extractor: -536870935",
"code": "TranslationWorker-RecoverableInternalFailure"
}
],
It was converted from an ifc format if that helps in any way.
We have tried this file in 360 and in forge with both revit and ifc before and translation has worked. I can provide a urn also.
As reported by #Glenit, it was missing some pieces on the resumable upload. For reference, this answer points out some samples on it.

Forge - Revit-UnsupportedFileType

I’m trying to integrate Forge viewer with my sample application and facing some issues.
Below are the steps I tried to achieve my goal.
Registered an app by creating a new account and generated “client ID” and “secret key” (success).
Generate Oauth token for further API calls (success).
Create a new bucket storage (success).
Upload model to the bucket and create URN for the model (success).
Design data for model translation (this is the step where our uploaded model will be translated to SVF) (success).
Check status of translated file. (success response but with error message as given below).
"messages":
[
{
"type": "error",
"code": "Revit-UnsupportedFileType",
"message": "The file is not a Revit file or is not a supported version."
},
{
"type": "error",
"message": "Possibly recoverable warning exit code from extractor: -536870935",
"code": "TranslationWorker-RecoverableInternalFailure"
}
],
Any help would be highly appreciated.
Are you able to upload & view the file using the public viewer? If so, most likely your upload routine (step 4) is corrupting the file. In this case, are you using resumable upload?
Samples for resumable upload:
C#
Nodejs

Box.com Content API: Add Collaboration

When using Box.Com APi, Add Collaboration method (https://developers.box.com/docs/#collaborations-add-a-collaboration) there's a parameter that states that its type is object (the accessible_by parameter). This is an example of something that is actually all over the documentation.
Reading the documentation, seems to me that these are objects in mini format, but they don't state the type.
Here is the object format for the accessible_by parameter used in the Create Collaboration endpoint:
"accessible_by": { "id": "USER_ID", "type": "user" }

Accessing Google AppEngine Cloud Endpoints using ActionScript 3?

Is anyone aware of method of accessing Google AppEngine Cloud Enpoints using ActionScript 3 without having to go through the JavaScript layer? I have been going on the docs and Google to find any tutorials or examples but did not find anything useful.
We don't have AS3 client libraries and currently there are none planned that I know of, so you'll have to rely on HTTP to make your REST calls.
TLDR; Use the APIs Explorer
If you visit
https://your-app-id.appspot.com/_ah/api/explorer
(replacing your-app-id with your actual application ID), then you'll be redirected to your own custom version of the Google APIs Explorer.
In it you can click on individual APIs and see the list of all available methods. Within a the page for each method, you can try out forming requests and the Explorer will suggest the correct values to use.
After you click "Execute", the full HTTP request (headers and all) and response will be printed on your page, which will show you which commands to use.
Description of how to use the Discovery Document
The Discovery Document for your API will contain all the information you need to construct a request.
To find the root for calling your API, check out the baseUrl key. It should be something like:
https://your-app-id.appspot.com/_ah/api/tictactoe/v1/
To figure out how to call a specific method, there are descriptions of every method, nested down as resources in the Discovery Document. For example, for the Tic Tac Toe Python sample, the board_get_move method has a name of board.getmove in the #endpoints.api decorator. This means the method getmove is owned by the resource board.
If you look in the resources.board.methods key in the Discovery Document you can see the getmove method:
"getmove": {
"id": "tictactoe.board.getmove",
"path": "board",
"httpMethod": "POST",
"description": "Exposes...",
"request": {
"$ref": "TictactoeApiMessagesBoardMessage"
},
"response": {
"$ref": "TictactoeApiMessagesBoardMessage"
}
}
Combining the path with our baseUrl we know requests will need to be sent to
https://your-app-id.appspot.com/_ah/api/tictactoe/v1/board
and from httpMethod we know requests will use the HTTP method POST.
Finally, to specify the request, we see a reference to a schema:
"$ref": "TictactoeApiMessagesBoardMessage"
Looking in the schemas.TictactoeApiMessagesBoardMessage key in the Discovery Document we see:
"TictactoeApiMessagesBoardMessage": {
"id": "TictactoeApiMessagesBoardMessage",
"type": "object",
"description": "ProtoRPC message definition to represent a board.",
"properties": {
"state": {
"type": "string"
}
}
}
so we know the payload must contain a single field called state and that field must be a string.