https://github.com/autodesk-forge/forge-viewmodels
View models from listof buckets and objects: This basic C# WebAPI back-end sample implements a basic list of Buckets and Objects with an Autodesk Forge 2-Legged Token
https://github.com/autodesk-forge/forge-viewmodels
autodesk-model-derivative autodesk-viewer csharp net-core
Last synced: 3 months ago
JSON representation
View models from listof buckets and objects: This basic C# WebAPI back-end sample implements a basic list of Buckets and Objects with an Autodesk Forge 2-Legged Token
- Host: GitHub
- URL: https://github.com/autodesk-forge/forge-viewmodels
- Owner: Autodesk-Forge
- License: mit
- Created: 2016-12-15T12:09:34.000Z (over 8 years ago)
- Default Branch: master
- Last Pushed: 2021-09-10T21:33:46.000Z (almost 4 years ago)
- Last Synced: 2025-04-12T08:53:58.427Z (3 months ago)
- Topics: autodesk-model-derivative, autodesk-viewer, csharp, net-core
- Language: C#
- Homepage:
- Size: 1.25 MB
- Stars: 21
- Watchers: 13
- Forks: 19
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# View Models (.NET Core C#)


[](http://opensource.org/licenses/MIT)[](http://developer.autodesk.com/)
[](http://developer.autodesk.com/)
[](http://developer.autodesk.com/)
[](http://developer.autodesk.com/)
# Description
This basic C# WebAPI back-end sample implements a basic list of Buckets and Objects with an [Autodesk Forge 2 Legged OAuth](https://developer.autodesk.com/en/docs/oauth/v2/tutorials/get-2-legged-token/). The front-end was desiged with pure HTML + JavaScript (jQuery, Bootstrap), no ASPx features (i.e. no WebForms or MVC on this sample). It includes: create and delete buckets, upload and delete object, translate (including `.zip` files). This code is based on [this tutorial](http://learnforge.autodesk.io).
## Thumbnail

# Setup
## Prerequisites
1. **Forge Account**: Learn how to create a Forge Account, activate subscription and create an app at [this tutorial](http://learnforge.autodesk.io/#/account/).
2. **Visual Studio**: Either Community 2017+ (Windows) or Code (Windows, MacOS).
3. **.NET Core** basic knowledge with C#
4. **JavaScript** basic knowledge with **jQuery**
5. **ngrok**: Routing tool, [download here](https://ngrok.com/)## Running locally
Clone this project or download it (this `netcore` branch only). It's recommended to install [GitHub desktop](https://desktop.github.com/). To clone it via command line, use the following (**Terminal** on MacOSX/Linux, **Git Shell** on Windows):
git clone github.com/Autodesk-Forge/model.derivative-WebAPI-sample.git
**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.

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:
```json
"env": {
"ASPNETCORE_ENVIRONMENT": "Development",
"ASPNETCORE_URLS" : "http://localhost:3000",
"FORGE_CLIENT_ID": "your id here",
"FORGE_CLIENT_SECRET": "your secret here",
"FORGE_WEBHOOK_URL": "your ngrok address here: e.g. http://abcd1234.ngrok.io",
},
```Run `ngrok http 3000` to create a tunnel to your local machine, then copy the address into the `FORGE_WEBHOOK_URL` environment variable.
## Deployment
To deploy this application to Heroku. After clicking on the button below, at the Heroku Create New App page, set your Client ID and Secret for Forge.
[](https://heroku.com/deploy)
# Further Reading
Documentation:
- [Data Management API](https://developer.autodesk.com/en/docs/data/v2/overview/)
- [Model Derivative API](https://forge.autodesk.com/en/docs/model-derivative/v2/developers_guide/overview/)
- [Viewer](https://developer.autodesk.com/en/docs/viewer/v6)### Tips & Tricks
This sample uses .NET Core and works fine on both Windows and MacOS, see [this tutorial for MacOS](https://github.com/augustogoncalves/dotnetcoreheroku).
### Troubleshooting
1. **error setting certificate verify locations** error: may happen on Windows, use the following: `git config --global http.sslverify "false"`
2. **Using Visual Studio 2015 (or older)**: unfortunately this version is not supported.
## License
This sample is licensed under the terms of the [MIT License](http://opensource.org/licenses/MIT). Please see the [LICENSE](LICENSE) file for full details.
## Written by
Augusto Goncalves [@augustomaia](https://twitter.com/augustomaia), [Forge Partner Development](http://forge.autodesk.com)