Frank P Archi Dev
Frank P Archi Dev

Reputation: 5

design-automation for Revit Autodesk.Revit.Exceptions.RevitServerUnauthenticatedUserException

I'm working with Design Automation using Postman. After posting work item I get an error regarding the SaveAsCloudModel() function. I tested this as a plugin for Revit and it works fine, now it's a Design Automation.

Any idea why I'm getting: Autodesk.Revit.Exceptions.RevitServerUnauthenticatedUserException: You must sign in to Autodesk 360 in order to complete this action. at Autodesk.Revit.DB.Document.SaveAsCloudModel(Guid accountId, Guid projectId, String folderId, String modelName)

The parameters provided work and are provided inside the C# code and has shown to work inside of Revit API as plugin. Just issue with DA.

Activity post:

{
            "id":"SaveModelTestActivity8",
            "commandLine": [ "$(engine.path)\\\\revitcoreconsole.exe /i \"$(args[rvtFile].path)\" /al \"$(appbundles[SaveModelTest8].path)\"" ],
            "parameters": {
              "rvtFile": {
                "zip": false,
                "ondemand": false,
                "verb": "get",
                "description": "Input Revit model",
                "required": true,
                "localName": "$(rvtFile)"
              },
              "result": {
                "zip": false,
                "ondemand": false,
                "verb": "put",
                "description": "Results",
                "required": true,
                "localName": "result.rvt"
              }
            },
            "engine": "Autodesk.Revit+2022",
            "appbundles": [ "SAVE_CLOUD_MODEL.SaveModelTest8+current" ],
            "description": "Save revit model"
    }

Work Item Post:

{
        "activityId": "SAVE_CLOUD_MODEL.SaveModelTestActivity8+current",
        "arguments": {
          "rvtFile": {
            "url": "https://cdn.us.oss.api.autodesk.com/oss/v2/signedresources/372091ac-8274-4187-95f0-22414d21c9f2?region=US",
            "pathInZip": "MYFILE.rvt"
          },
          "result": {
            "verb": "put",
            "url": "https://cdn.us.oss.api.autodesk.com/oss/v2/signedresources/372091ac-8274-4187-95f0-22414d21c9f2?region=US"
          }     
        }
      }

I tried looking up more documentation on the error, and struggling to find resources regarding this error inside of design automation. I'm expecting to use the SaveAsCloudModel(). Ultimately I want to be able to save a cloud share model to BIM360, as part of our project creation automation. We create folders with a default naming convention and structure where we want to also publish a model into that folder. We already have the folder process figured out, just need to get the cloud share model in place.

-Default Top Folder -Folder -Folder -project.rvt

Upvotes: 0

Views: 272

Answers (1)

Rahul Bhobe
Rahul Bhobe

Reputation: 4451

It works on your desktop version because you are logged in and you have access to the Hub / Project folder. If you log out from the widget in top right corner you would have the same exception.

Similarly, in your workitem post you need to pass on the user context to Design Automation for Revit. This can be done adding adsk3LeggedToken argument to the workitem call. This is a special argument that does not require corresponding parameter defined at the activity.

Read more details in this blog.

As an example see here:

{
  "activityId": "SAVE_CLOUD_MODEL.SaveModelTestActivity8+current",
  "arguments": {
    "rvtFile": {
      "url": "workingurldownload",
      "pathInZip": "XXXXX_JLG Revit2021 Starter File_A_detached.rvt",
    },
    "result": {
      "verb": "put",
      "url": "outputurl"
    }
    "adsk3LeggedToken": "token"
  }
}

Upvotes: 1

Related Questions