Show BIM 360 Hubs, Projects and Files, based on this tutorial. When select a folder on the tree view, the option to "Start watching folder" allow to create a dm.version.added
webhook for that folder. When a new file is uploaded (e.g. via BIM 360 Docs UI) the webhook notifies the app, which queues the job to, later when ready, access the metadata of the file.
There a few moving parts on this sample, this video demonstrates the sample.
- Forge Account: Learn how to create a Forge Account, activate subscription and create an app at this tutorial.
- Visual Studio: Either Community (Windows) or Code (Windows, MacOS).
- .NET Core basic knowledge with C#
- ngrok: Routing tool, download here
- MongoDB: noSQL database, learn more. Or use a online version via mLab (this is used on this sample)
Clone this project or download it. It's recommended to install GitHub desktop. To clone it via command line, use the following (Terminal on MacOSX/Linux, Git Shell on Windows):
git clone https://github.com/autodesk-forge/data.management-csharp-webhook
Visual Studio (Windows):
Right-click on the project, then go to Debug. Adjust the settings as shown below.
Visual Sutdio Code (Windows, MacOS):
Open the folder, at the bottom-right, select Yes and Restore. This restores the packages (e.g. Autodesk.Forge) and creates the launch.json file. See Tips & Tricks for .NET Core on MacOS.
MongoDB
MongoDB is a no-SQL database based on "documents", which stores JSON-like data. For testing purpouses, you can either use local or live. One easy way is using mLab.
- Create a account
- Create a new database (e.g. named
webhooks
) - Under Collections, add a new
users
collection - Under Users, add a new database user, e.g.
appuser
At this point the connection string should be in the form of mongodb://<dbuser>:<dbpassword>@ds<number>.mlab.com:<port>/webhook
.
There are several tools to view your database, Robo 3T (formerly Robomongo) is a free lightweight GUI that can be used. When it opens, click on Create, then at Connection specify a name
, enter your ds<number>.mlab.com
as address and <port>
number as port, also at Authentication enter the datbase name (e.g. webhook
) and <dbuser>
and <dbpassword>
.
Environment variables
At the .vscode\launch.json
, find the env vars and add your Forge Client ID, Secret and callback URL. Also define the ASPNETCORE_URLS
variable. The end result should be as shown below:
"env": {
"ASPNETCORE_ENVIRONMENT": "Development",
"ASPNETCORE_URLS" : "http://localhost:3000",
"FORGE_CLIENT_ID": "your id here",
"FORGE_CLIENT_SECRET": "your secret here",
"FORGE_CALLBACK_URL": "http://localhost:3000/api/forge/callback/oauth",
"FORGE_WEBHOOK_CALLBACK_URL": "http://1234.ngrok.io/api/forge/callback/webhook",
"OAUTH_DATABASE": "mongodb://<dbuser>:<dbpassword>@ds<number>.mlab.com:<port>/webhook"
},
Open http://localhost:3000
to start the app.
Open http://localhost:3000/hangfire
for jobs dashboard.
To deploy this application to Heroku, the Callback URL for Forge must use your .herokuapp.com
address. After clicking on the button below, at the Heroku Create New App page, set your Client ID, Secret and Callback URL for Forge.
Documentation:
Other APIs:
- Hangfire queueing library for .NET
- MongoDB for C# driver
- mLab Database-as-a-Service for MongoDB
- No webhook for translation: this sample tries
GET Manifest
every interval as, as of now, there is no webhook for Model Derivative translations on BIM 360 files. There is support for OSS Buckets translations, learn more here.
This sample uses .NET Core and works fine on both Windows and MacOS, see this tutorial for MacOS.
-
Cannot see my BIM 360 projects: Make sure to provision the Forge App Client ID within the BIM 360 Account, learn more here. This requires the Account Admin permission.
-
error setting certificate verify locations error: may happen on Windows, use the following:
git config --global http.sslverify "false"
This sample is licensed under the terms of the MIT License. Please see the LICENSE file for full details.
Augusto Goncalves @augustomaia, Forge Partner Development