Http

The Http activity can be used to integrate the Anthology platform with external systems. The activity supports REST and SOAP web services. It enables posting messages, retrieving data, returning status results, and other actions related to a specific resource.

Anthology applications use this activity to post messages to the Azure Service Bus and Azure Logic Apps, Microsoft Flow and Office 365, as well as any other external Web APIs. Anthology Student Finance, HR & Payroll uses this activity to integrate Anthology Student and Dynamics 365.

The Http activity will execute (send) a request and you will get a response from the Url end-point that is being posted to. For the SendToAzureServiceBus activity, the workflow logic cannot depend on getting an immediate result from the process –- all you will know is that the message was successfully queued. If you want to get or post data and want to know the result immediately (synchronously), use the Http activity. For more information, see example Http vs. SendToAzureServiceBus.

Properties pane

Properties

Http Activity Properties
Property Value Required Notes
Body InArgument<String> No Represents data to be transferred in the HTTP request to the server.
DisplayName String No Specify a name for the activity or accept the default.
Headers InArgument<StringDictionary> No Represents the name/value pairs that are transferred in the request.
MediaType InArgument<String> Yes The media type of the body of the request. (e.g., “application/json”). Media type is typically used with POST, PUT, PATCH methods/verbs.
Method InArgument<String> Yes HTTP method that indicates the action to be performed for a given resource: GET, POST, PUT, HEAD, DELETE, PATCH, CONNECT, OPTIONS, TRACE
ResponseBody OutArgument<String> No The response body returned from the server.
ResponseStatusCode OutArgument<HttpStatusCode> No Represents the HTTP response status code issued by the server in response to the request (e.g., 200, 401, 500, etc.).
URI InArgument<String> Yes The Universal Resource Identifier to which the request will be made (e.g., “https://www.host.com/resource”).

Examples

Invoke an Azure Logic App

The workflow example below is available on GitHub. Refer to the instructions at https://github.com/campusmanagement/workflow-samples/blob/master/README.md.

This example shows how the Http activity can be used to invoke an Azure logic app. The xaml file is available here: Cmc.Nexus.Crm.Entities.TaskEntity_SavingEvent_Sample - Azure Logic Apps.xaml.

Example - Invoke Azure Logic App

  1. The SerializeToJson activity serializes an input argument object named "entity" and produces the output string named "message".

    SerializeToJson

  2. The next activity is an Http activity. It:

    • Uses the serialized "message" string as input argument in the Body property.
    • Defines the input as MediaType = "application/json".
    • Invokes the "POST" method.
    • Creates the output argument named "responseBody".
    • Sends the output to URI = "https://logicAppUrl" using the POST method.

    Http - Invoke Azure Logic App

  3. The If activity validates the output from the Http activity using the following Boolean condition:

    not string.IsNullOrEmpty(responseBody)

    The string.IsNullOrEmpty(responseBody) method checks whether the specified string (i.e., responseBody) is null or an empty string ("").

    Condition

    • If the condition is met (i.e., the responseBody string is empty), the CreateValidationItem activity creates an error message.

      Validation

    • If the condition is not met, the responseBody string is sent to the URI specified in the Http activity

Invoke an Azure Function

The workflow example below is available on GitHub. Refer to the instructions at https://github.com/campusmanagement/workflow-samples/blob/master/README.md.

This example shows how the Http activity can be used to invoke an Azure function. The xaml file is available here: Cmc.Nexus.Crm.Entities.TaskEntity_SavingEvent_Sample - Azure Functions.xaml.

Example - Invoke Azure Function

  1. The SerializeToJson activity serializes an input argument object named "entity" and produces the output string named "message".

    SerializeToJson

  2. The next activity is an Http activity. It:

    • Uses the serialized "message" string as input argument in the Body property.
    • Defines the input as MediaType = "application/json".
    • Invokes the "POST" method.
    • Creates the output argument named "responseBody".
    • Sends the output to URI = "https://azureFunctionUrl" using the POST method.

    Http - Invoke Azure Function

  3. The If activity validates the output from the Http activity using the following Boolean condition:

    not string.IsNullOrEmpty(responseBody) AND responseBody <> """"""

    The string.IsNullOrEmpty(responseBody) method checks whether the specified string (i.e., responseBody) is null or an empty string ("").

    Condition

    • If the condition is met (i.e., the responseBody string is empty), the CreateValidationItem activity creates an error message.

      Validation

    • If the condition is not met, the responseBody string is sent to the URI specified in the Http activity

Http vs. SendToAzureServiceBus

To demonstrate the difference between the Http and SendToAzureServiceBus activities, we created a workflow that multiplies two numbers (24 x 365) and returns the result (8,760).

  • The Http activity returns the result immediately to a workflow variable.

  • The SendToAzureServiceBus activity sends the result to the service bus where it is processed by an application that is listening for messages. Then response is sent to the email address specified in the request.

    In more complex scenarios, the response from the service bus listener process could be a call back into another system –- or the service bus listener would forward the message to a 3rd party application to be posted to that system.

The workflow uses the following variables:

Http Activity

Http Example

The Http activity:

  • Uses the string assignments (nbr1 and nbr2) as input arguments in the Body property.
  • Defines the input as MediaType = "application/json".
  • Invokes the "POST" method.
  • Creates the output argument named "httpResponseBody".
  • Creates the output argument named "httpResponseStatus" whose value is checked in the If Condition.
  • Sends the output to a Uri on an Azure web site that hosts an API.

The API multiplies the numbers 2 numbers in the request Body (nbr1 and nbr2) and returns the result.

Http Properties

 

SendToAzureServiceBus Activity

SendToAzureServiceBus Properties

The SendToAzureServiceBus activity:

  • Sends the string assignments (nbr1 and nbr2) and "emailTo" variable to the Azure Service Bus.
  • Specifies the path for the Azure Service Bus as "mathqueue".
  • Specifies the user's service name space and access key in Azure.

In Azure, the message is placed in the "mathqueue" and processed.

SendToAzureServiceBus Properties

When the service bus request is processed, an email is sent to the user.

SendToAzureServiceBus Properties