Search code examples
c#ajaxautodesk-forgeautodesk-data-managementautodesk-designautomation

Error uploading Autodesk design automation, dotnet Core..... 1 rfa and 1 big Json file to pass as input


The Revit Addin is working perfectly and I have also converted correctly for Design automation. I have debugged it with local debugger. It worked perfect. So I can say app bundle is perfectly doing well.

Now coming to the web application code, it works perfect until last line of "workItemStatus". I need a rfa file and a big Json file as input file, to run the code. Both together will be 1 mb in size. But code is stack (endlessly waiting) when uploading file, workitem does not start. I read in another stackoverflow post, that Forge does not allow more than 16kb upload to oss bucket by..... Url = string.Format("https://developer.api.autodesk.com/oss/v2/buckets/{0}/objects/{1}", bucketKey, inputFileNameOSS) That post says, I will need to upload bigger files to another cloud service and use the signed-in URL instead of Forge oss bucket.

The code looks correct while debugging and it is stack, when it reach to the line WorkItemStatus workItemStatus = await _designAutomation.CreateWorkItemAsync(workItemSpec);

I have debugged the code, looks like perfectly working until "workItemStatus" value, in DesignAutomationController.cs "StartWorkItem". Every Key and Value looks perfectly passed. Is it because of the file size ? As the Json file is big, I am uploading it like the other input (.rfa/.rvt) files.


string callbackUrl = string.Format("{0}/api/forge/callback/designautomation?id={1}&outputFileName={2}", OAuthController.GetAppSetting("FORGE_WEBHOOK_URL"), browerConnectionId, outputFileNameOSS);
            WorkItem workItemSpec = new WorkItem()
            {
                ActivityId = activityName,
                Arguments = new Dictionary<string, IArgument>()
                {
                    { "inputFile", inputFileArgument },
                    { "inputJsonFile", inputFileArgument1 },
                    { "outputFile", outputFileArgument },
                    { "onComplete", new XrefTreeArgument { Verb = Verb.Post, Url = callbackUrl } }
                }
            };
            ***WorkItemStatus workItemStatus = await _designAutomation.CreateWorkItemAsync(workItemSpec);***

            return Ok(new { WorkItemId = workItemStatus.Id }); ```


Solution

  • I read in another stackoverflow post, that Forge does not allow more than 16kb upload to oss bucket by..

    The 16kb limit is on a payload of design automation endpoints including the workitem. The limits are defined here. If the workitem payload exceeds 16kb you will see an error HTTP 413 Payload Too Large.

    To send large json inputs to design automation, you may first upload the json to OSS (or even another storage service such as Amazon S3). Then call the workitem with a signed url to the json file (similar to the signed url for the rfa file).

    Edit:
    1. Large JSON files can be uploaded to OSS using Data Management endpoint.
    2. A signed URL with read access can then be obtained for that object using endpoint.
    3. The URL obtained can then be passed to Design Automation workitem payload as an input argument, instead of embedding the json contents into the payload.