I'm developing a simple web console that a user can use to start workflows. I have a simple web server that listens for incoming requests and starts the workflow.
This WFSO code works:
using System.Collections.Generic;
using System.Web.Mvc;
using Laserfiche.Workflow;
using Laserfiche.Workflow.Objects;
namespace WFWeb.Controllers
{
public class WorkflowController : Controller
{
//
// GET: /Workflow/RunWF/5
public void RunWF(int id)
{
string workflowServer = "localhost";
string workflowApplication = "My App";
using (WorkflowConnection connection = WorkflowConnection.CreateConnection(workflowServer, workflowApplication))
{
string workflowName = "Test WF";
Database database = connection.Database;
PublishedWorkflow workflow = database.GetPublishedWorkflow(workflowName);
string ruleName = "My Rule";
StartingEntry entry = null;
Initiator initiator = null;
WorkflowCreationOptions options = null;
Dictionary<string, string> parameters = new Dictionary<string, string>
{
{ "workflowID", id.ToString() }
};
workflow.StartWorkflow(ruleName, entry, initiator, options, parameters);
}
}
}
}
This WorkflowRestAPI code doesn't:
using System.Web.Mvc;
using WFWeb.WorkflowRestAPI;
namespace WFWeb.Controllers
{
public class WorkflowController : Controller
{
//
// GET: /Workflow/RunWF/5
public void RunWF(int id)
{
using (WorkflowAPIBaseClient WorkflowService = new WorkflowAPIBaseClient())
{
InstanceCreationData creationData = new InstanceCreationData();
creationData.StartingEntry = new InstanceEntryData();
creationData.Initiator = new InstanceUserData();
creationData.Initiator.InitiatorName = "Admin";
InstanceParameterData firstName = new InstanceParameterData();
creationData.ParameterCollection = new InstanceParameterCollection();
creationData.ParameterCollection.Add(firstName);
creationData.RuleName = "My Rule";
string workflowName = "Test WF";
InstanceCreationResultData results = WorkflowService.CreateWorkflowInstance(workflowName, creationData);
string instanceID = results.instanceId;
string fault = results.fault != null ? results.fault.Detail : string.Empty;
}
}
}
}
Nothing happens and there are no errors reported anywhere.
I also tried to send a POST request directly to http://localhost:81/Workflow/api/instances/{WORKFLOWNAME} with a JSON body containing the example data located at /Workflow/api/help/operations/CreateWorkflowInstance, but kept getting "Bad Request" and gave up. That would be my ideal approach, since Workflow already has a web service and all I need is to start a workflow, so if anyone has thoughts I'm all ears. ![]()