Search code examples
c#autodesk-designautomation

Notification workitem completing without polling on v3


it seems that there is a way to achieve non polling mechanism to get the completion of a workitem as said on this page : https://forge.autodesk.com/en/docs/design-automation/v3/developers_guide/basics/ But I can't find a way to specify it using the api. What am I supposed to define in the workitem to have a callback on a specific endpoint?

This is what I already have :

var workITem = new WorkItem
            {
                ActivityId = Services.ForgeService.CleanActivityId,
                Arguments = new Dictionary<string, IArgument>
                {
                    {
                        "dwg",
                        new XrefTreeArgument
                        {
                            Url = inputUrl,
                            Verb = Verb.Get
                        }
                    },
                    {
                        "results",
                        new XrefTreeArgument
                        {
                            Verb = Verb.Put,
                            Headers = new Dictionary<string, string>
                            {
                                {"Authorization", $"Bearer {token}"}
                            },
                            Url = outputUrl
                        }
                    }
                }
            };

Thanks.


Solution

  • Romain,

    Please go through the LearnForge tutorial

    string callbackUrl = "Your Callback Url";
        WorkItem workItemSpec = new WorkItem()
        {
            ActivityId = activityName,
            Arguments = new Dictionary<string, IArgument>()
            {
                { "inputFile", inputFileArgument },
                { "inputJson",  inputJsonArgument },
                { "outputFile", outputFileArgument },
                { "onComplete", new XrefTreeArgument { Verb = Verb.Post, Url = callbackUrl } }
            }
        };