10 Nov 2016

Translate using Item Version id

By Adam Nagy (@AdamTheNagy)

In order to get a file on A360 translated and show it in the viewer, so far you needed to drill down to the file on OSS (Object Storage System) and use its id/urn to get it translated using the Model Derivative API. Just like it's shown in this blog post.

Now you can simply use the id of the Item Version. The main benefit of this is that this way you have access to the translation already requested by the A360 UI. When you upload a file to A360 through its webpage then it will automatically kick off the SVF translation so that it will be viewable on the web. Now you have access to this translation.

For comparison, let's use the same response body that was used in the previous blog post. Now instead of using the id highlighted in red, you can use the one highlighted in green.

{
      "type": "versions",
      "id": "urn:adsk.wipprod:fs.file:vf.6bVr4EVDSaOpykczeQYR2Q?version=1",
      "attributes": {
        "name": "House Design.rvt",
        "displayName": "House Design.rvt",
        "createTime": "2016-05-24T19:25:23+00:00",
        "createUserId": "38SCJGX4R4PV",
        "lastModifiedTime": "2016-05-24T19:25:23+00:00",
        "lastModifiedUserId": "38SCJGX4R4PV",
        "versionNumber": 1,
        "mimeType": "application/vnd.autodesk.revit",
        "fileType": "rvt",
        "storageSize": 12550144,
        "extension": {
          "type": "versions:autodesk.core:File",
          "version": "1.0",
          "schema": {
            "href": "https://developer.api.autodesk.com/schema/v1/versions/versions%3Aautodesk.core%3AFile-1.0"
          },
          "data": {}
        }
      },
      "links": {
        "self": {
          "href": "https://developer.api.autodesk.com/data/v1/projects/a.cGVyc29uYWw6cGUyOWNjZjMyI0QyMDE2MDUyNDEyOTI5NzY/versions/urn:adsk.wipprod:fs.file:vf.6bVr4EVDSaOpykczeQYR2Q%3Fversion%3D1"
        }
      },
      "relationships": {
        "item": {
          "data": {
            "type": "items",
            "id": "urn:adsk.wipprod:dm.lineage:6bVr4EVDSaOpykczeQYR2Q"
          },
          "links": {
            "related": {
              "href": "https://developer.api.autodesk.com/data/v1/projects/a.cGVyc29uYWw6cGUyOWNjZjMyI0QyMDE2MDUyNDEyOTI5NzY/versions/urn:adsk.wipprod:fs.file:vf.6bVr4EVDSaOpykczeQYR2Q%3Fversion%3D1/item"
            }
          }
        },
        "refs": {
          "links": {
            "self": {
              "href": "https://developer.api.autodesk.com/data/v1/projects/a.cGVyc29uYWw6cGUyOWNjZjMyI0QyMDE2MDUyNDEyOTI5NzY/versions/urn:adsk.wipprod:fs.file:vf.6bVr4EVDSaOpykczeQYR2Q%3Fversion%3D1/relationships/refs"
            },
            "related": {
              "href": "https://developer.api.autodesk.com/data/v1/projects/a.cGVyc29uYWw6cGUyOWNjZjMyI0QyMDE2MDUyNDEyOTI5NzY/versions/urn:adsk.wipprod:fs.file:vf.6bVr4EVDSaOpykczeQYR2Q%3Fversion%3D1/refs"
            }
          }
        },
        ... 
        "storage": {
          "data": {
            "type": "objects",
            "id": "urn:adsk.objects:os.object:wip.dm.prod/977d69b1-43e7-40fa-8ece-6ec4602892f3.rvt"
          },

Here is some graphics to help explain the change:

ModelDerivativeJob2

In case the translation did not trigger for some reason, or you want to translate to a different format you can do it like this. Once you have the id (in case of our example urn:adsk.wipprod:fs.file:vf.6bVr4EVDSaOpykczeQYR2Q?version=1) you just have to base64 encode it and use that with the Model Derivative API to post an svf translation job for that file:
https://developer.autodesk.com/en/docs/model-derivative/v2/tutorials/prepare-file-for-viewer/

That's it.

Note: you need to use URL safe base64 encoding (RFC 6920) which has '_' instead of '/', '-' instead of '+', and no '=' padding at the end. This is also described on this wiki page in the "Unpadded 'base64url' for "named information" URI's (RFC 6920)" row of the comparison table

Tags:

Related Article