/// <summary>
        /// Create Bucket
        /// </summary>
        private async Task <IActionResult> CreateBucket()
        {
            dynamic oauth = await OAuthController.GetInternalAsync();

            string     bucketkey  = "inventorilogicda" + nickName.ToLower();
            BucketsApi bucketsApi = new BucketsApi();

            bucketsApi.Configuration.AccessToken = oauth.access_token;
            dynamic buckets = await bucketsApi.GetBucketsAsync();

            bool bucketExists = buckets.items.ToString().Contains(bucketkey);

            if (!bucketExists)
            {
                PostBucketsPayload postBucket = new PostBucketsPayload(bucketkey, null, PostBucketsPayload.PolicyKeyEnum.Transient);
                dynamic            newbucket  = await bucketsApi.CreateBucketAsync(postBucket);
            }
            return(Ok());
        }
        /// <summary>
        /// Translate object
        /// </summary>
        private async Task <dynamic> TranslateObject(dynamic objModel, string outputFileName)
        {
            dynamic oauth = await OAuthController.GetInternalAsync();

            string objectIdBase64 = ToBase64(objModel.objectId);
            // prepare the payload
            List <JobPayloadItem> postTranslationOutput = new List <JobPayloadItem>()
            {
                new JobPayloadItem(
                    JobPayloadItem.TypeEnum.Svf,
                    new List <JobPayloadItem.ViewsEnum>()
                {
                    JobPayloadItem.ViewsEnum._2d,
                    JobPayloadItem.ViewsEnum._3d
                })
            };
            JobPayload job;

            job = new JobPayload(
                new JobPayloadInput(objectIdBase64, false, outputFileName),
                new JobPayloadOutput(postTranslationOutput)
                );

            // start the translation
            DerivativesApi derivative = new DerivativesApi();

            derivative.Configuration.AccessToken = oauth.access_token;
            dynamic jobPosted = await derivative.TranslateAsync(job, true);

            // check if it is complete.
            dynamic manifest = null;

            do
            {
                System.Threading.Thread.Sleep(1000); // wait 1 second
                try
                {
                    manifest = await derivative.GetManifestAsync(objectIdBase64);
                }
                catch (Exception) { }
            } while (manifest.progress != "complete");
            return(jobPosted.urn);
        }
        // <summary>
        // Creates WorkItem
        // </summary>
        private async Task <IActionResult> CreateWorkItem(ModelAttributes param)
        {
            // OAuth token
            dynamic oauth = await OAuthController.GetInternalAsync();

            string bucketkey           = "inventorilogicda" + nickName.ToLower();
            string qualifiedActivityId = string.Format("{0}.{1}+{2}", nickName, ACTIVITY_NAME, ALIAS);

            // input json
            dynamic inputJson = new JObject();

            inputJson.Material     = param.color;
            inputJson.Diameter     = param.diameter;
            inputJson.Spoke_Design = param.rim;
            inputJson.Width        = param.width;
            inputJson.InputIPT     = "RIM.ipt";
            inputJson.InputIDW     = "RIM.idw";

            XrefTreeArgument inputJsonArgument = new XrefTreeArgument()
            {
                Url = "data:application/json, " + ((JObject)inputJson).ToString(Formatting.None).Replace("\"", "'")
            };

            //  output IPT file
            XrefTreeArgument outputIPTFileArgument = new XrefTreeArgument()
            {
                Url     = string.Format("https://developer.api.autodesk.com/oss/v2/buckets/{0}/objects/{1}", bucketkey, outputIPTFile),
                Verb    = Verb.Put,
                Headers = new Dictionary <string, string>()
                {
                    { "Authorization", "Bearer " + oauth.access_token }
                }
            };

            //  output IDW file
            XrefTreeArgument outputIDWFileArgument = new XrefTreeArgument()
            {
                Url     = string.Format("https://developer.api.autodesk.com/oss/v2/buckets/{0}/objects/{1}", bucketkey, outputIDWFile),
                Verb    = Verb.Put,
                Headers = new Dictionary <string, string>()
                {
                    { "Authorization", "Bearer " + oauth.access_token }
                }
            };

            //  output PDF file
            XrefTreeArgument outputPDFFileArgument = new XrefTreeArgument()
            {
                Url     = string.Format("https://developer.api.autodesk.com/oss/v2/buckets/{0}/objects/{1}", bucketkey, outputPDFile),
                Verb    = Verb.Put,
                Headers = new Dictionary <string, string>()
                {
                    { "Authorization", "Bearer " + oauth.access_token }
                }
            };

            string   callbackUrl  = string.Format("{0}/api/forge/callback/designautomation?id={1}", OAuthController.GetAppSetting("FORGE_WEBHOOK_URL"), param.browserconnectionId);
            WorkItem workItemSpec = new WorkItem()
            {
                ActivityId = qualifiedActivityId,
                Arguments  = new Dictionary <string, IArgument>()
                {
                    { "inputJson", inputJsonArgument },
                    { "ResultIPT", outputIPTFileArgument },
                    { "ResultIDW", outputIDWFileArgument },
                    { "ResultPDF", outputPDFFileArgument },
                    { "onComplete", new XrefTreeArgument {
                          Verb = Verb.Post, Url = callbackUrl
                      } }
                }
            };
            WorkItemStatus workItemStatus = await _designAutomation.CreateWorkItemAsync(workItemSpec);

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