WebHook API execute two time with Design Automation

74 Views Asked by At

I have issue with callback from Webhook Services trigger event from ACC, the problem is process execute two time. Can I know the reason, this is my code :

  [HttpPost]
    [Route("api/forge/callback/webhook")]
    public async Task<IActionResult> WebhookCallback([FromBody] JObject body)
    {
        // catch any errors, we don't want to return 500
        try
        {
            string projectId = "b." + body["payload"]["project"];
            string versionId = body["resourceUrn"].ToString();
            string modelName = body["payload"]["name"].ToString();
            // remove 4 chars from the end (.rvt)
            modelName = modelName.Substring(0, modelName.Length - 4);
            string stormProcessState = body["payload"]["custom-metadata"]["storm:process-state"].ToString();


            // do you want to filter events??
            //if (eventType != "dm.version.added") return Ok();

            // your webhook should return immediately!
            // so can start a second thread (not good) or use a queueing system (e.g. hangfire)

            // starting a new thread is not an elegant idea, we don't have control if the operation actually complets...

           
            RevitDesignAutomate revitDesignAutomate = new RevitDesignAutomate(designAutomateConfiguration);
            string callback = "https://webhook.site/25ad18c1-2f09-4148-bfd1-2c8cd2418a9b";
            await revitDesignAutomate.ExecuteJob(projectId, versionId,modelName, callback);
           
        }
        catch(Exception e)
        {
            Console.WriteLine(e.Message);
        }

        // ALWAYS return ok (200)
        return Ok();
    }

Any help appreciated.

0

There are 0 best solutions below