Search code examples
.netautodesk-forgeautodesk

Autodesk Forge .net SDK Get Object


I'm having trouble using the Forge .net SDK to download a file from a bim 360 docs hub.

I'm using three legged Authentication with the following scopes :-

data:read data:write data:create data:search bucket:create bucket:read bucket:update bucket:delete

It gives me the following error:-

Error calling GetObject: {"developerMessage":"ACM check failed, user or calling service does not have access to perform this operation","userMessage":"","errorCode":"AUTH-012","more info":"http://developer.api.autodesk.com/documentation/v1/errors/AUTH-012"}

Code for the Get call below, bucket key and object name are coming from the storage location of the item as per step 4 in this example https://developer.autodesk.com/en/docs/data/v2/tutorials/download-file/

Bucket key is wip.dm.prod & object name is random guid & ".dwg"

    Dim objectsAPI As New ObjectsApi()
    objectsAPI.Configuration.AccessToken = accessToken
    bucketKey = System.Convert.ToBase64String(System.Text.Encoding.UTF8.GetBytes(bucketKey))
    objectName = System.Convert.ToBase64String(System.Text.Encoding.UTF8.GetBytes(objectName))

    Dim objFile As IO.Stream = objectsAPI.GetObject(bucketKey, objectName)
    Using fStream As New IO.FileStream(downloadPath, FileMode.CreateNew)
        objFile.CopyTo(fStream)
    End Using

Solution

  • Working now, just didn't need to encode the bucket key and object name before passing in to GetObject