Skip to content

Invoke Workflow action

MarkAbrams edited this page Feb 6, 2024 · 2 revisions

This is an example of JSON request and response message content for a mocked Invoke Workflow action.

Request

The name of the invoked workflow is located in the host.workflow.id field. An invoked workflow must have a HTTP trigger and any HTTP request headers are located in the headers field and the request body is located in the body field.

{
  "host": {
    "workflow": {
      "id": "managed-api-connector-test-workflow"
    }
  },
  "headers": {
    "Content-Type": "application/json",
    "DataSource": "customers",
    "Priority": false
  },
  "body": {
    "id": 54624,
    "title": "Mr",
    "firstName": "Peter",
    "lastName": "Smith",
    "dateOfBirth": "1970-04-25",
    "address": {
      "addressLine1": "The Old Station",
      "addressLine2": "High Street",
      "addressLine3": "",
      "town": "Some Town",
      "county": "Some County",
      "postcode": "AB12 6ZZ",
      "countryCode": "UK",
      "countryName": "United Kingdom"
    }
  }
}

Successful Response

The response must match the response that would have been generated by the invoked workflow. For example, this code mocks a response using the Fluent API that returns plain text:

testRunner
    .AddMockResponse("Invoke-Workflow",
        MockRequestMatcher.Create()
        .UsingPost())
    .RespondWith(
        MockResponseBuilder.Create()
        .WithSuccess()
        .WithContentAsPlainText("Upsert is successful"));

Failed Response

Failure scenarios can be triggered by returning a response with a non-success status code. If response content is used, this must match the response that would have been generated by the invoked workflow for the failure scenario. For example, this code mocks a response using the Fluent API that returns a HTTP 404 (Not Found) status code and no response content:

testRunner
    .AddMockResponse("Invoke-Workflow",
        MockRequestMatcher.Create()
        .UsingPost())
    .RespondWith(
        MockResponseBuilder.Create()
        .WithNotFound());
Clone this wiki locally