protected override async Task <WorkflowResult> LaunchWorkflow(ProvisioningConfiguration configuration, ConsumeContext <RepresentationAddedEvent> context)
        {
            using (var httpClient = new HttpClient())
            {
                var processInstanceId = await CreateProcessInstance(configuration, httpClient);
                await LaunchProcessInstance(processInstanceId, configuration, httpClient);
                await RaiseEvent(processInstanceId, configuration, context, httpClient);

                return(new WorkflowResult(processInstanceId, configuration.GetBpmnFileId()));
            }
        }
        private async Task <string> CreateProcessInstance(ProvisioningConfiguration configuration, HttpClient httpClient)
        {
            var content = new JObject();

            content.Add("processFileId", configuration.GetBpmnFileId());
            var request = new HttpRequestMessage
            {
                RequestUri = new Uri($"{configuration.GetBpmnEndpoint()}/processinstances"),
                Method     = HttpMethod.Post,
                Content    = new StringContent(content.ToString(), Encoding.UTF8, "application/json")
            };
            var httpResult = await httpClient.SendAsync(request);

            httpResult.EnsureSuccessStatusCode();
            var str = await httpResult.Content.ReadAsStringAsync();

            return(JObject.Parse(str).SelectToken("content[0].id").ToString());
        }