18 Oct 2017

Update BIM360 Docs File Version with Insomnia REST and Data Management API

Default blog image

In my last post I shared the discovery of an App that I've been using quite often since I came across, the name is Insomnia

This time I tried to create a workflow using the app in order to Upload to BIM 360 Docs, but since I was already helping one of our customers with the Update version I decided to create the following video. 

Let me explain the workflow of what I'm currently doing with every endpoint I reach on the App. 

  1. Authenticate with a 3 Legged Token (OAuth 2 setup in Insomnia)
  2. GET Hubs call
  3. GET Projects call
  4. GET Folders
    1. GET SubFolder
  5. POST Storage Location
  6. POST Upload to Storage Location
  7. POST Create 1st Version of Uploaded file.

That will be the first part to upload the File for the first time. Now let's do this for updating the version of that file. The same process can be applied for 2,3,4....1000 versions of the same file. We will need to repeat Step 5 and 6 in order to create the updated version.

  1. POST Storage Location (use the new ObjectID obtained here)
  2. POST Upload to the New Storage Location, same file with same name
  3. POST Update file version. In this step the end-point will be different from the creation of the first version. 

Here is the cURL call to better explain this. 

curl --request POST \
  --url https://developer.api.autodesk.com/data/v1/projects/b.e6d7a065-e57d-4abc-89c3-caf8xxxxxx/versions \
  --header 'authorization: Bearer YOUR3LEGGEDTOKEN' \
  --header 'content-type: application/vnd.api+json' \
  --data '{
   "jsonapi": { "version": "1.0" },
   "data": {
      "type": "versions",
      "attributes": {
         "name": "rac_basic_sample_project-insomnia.rvt",
         "extension": { "type": "versions:autodesk.bim360:File", "version": "1.0"}
      "relationships": {
         "item": { "data": { "type": "items", "id": "urn:adsk.wipprod:dm.lineage:7S64e6zLTNyr0j6tmkIX2x" } },
         "storage": { "data": { "type": "objects", "id": "urn:adsk.objects:os.object:wip.dm.prod/8942c6a7-a72b-46d4-8873-ed2c965a3cfe.rvt" } }

If you notice in the Data above, we will need to make note of the new object ID in Step 1 (Update version process). Get the item ID of the response JSON from Step 7 (first version of the file) or call the GET projects/:project_id/folders/:folder_id/contents endpoint. 

Here is the Video demonstrating all the steps explained previously. 

Related Article