Lab 3: Deploy and Run the Campaigns Flow


Let’s now test the flow end-end and examine the various capabilities that Flow Designer provides.

Step 1: Run the application

Like we did in Lab 1, we are going to deploy the API.

  1. Press the Run button.

    module4 lab3 run button
  2. Wait until you see the message Running

    module4 lab3 latest changes deployed

Step 2: Test the Application

  1. Clicking on the three dots beside the Deploy button, it will display a Menu

    module4 lab3 display menu

    We will give a description of each item

    • Copy link: This option will copy the API URL to the clipboard.

    • Pause: This option pauses the API execution.

    • View in Runtime Manager: This option goes to the runtime manager and you can see the application deployed in Mule Runtime

    • Open logs: This option shows the Runtime logs online.

    • Restart workspace: This option will restart the deployed application in the same way as you will do in in the Runtime Manager section.

  2. For testing purpose we are going to select the Copy link option.

  3. Open the Chrome browser and open the Restlet Client extension.

    module4 lab3 restlet client
    You could use Postman or any other Rest Client.
  4. Paste the URL you just copied and append /campaigns to the URL

    module4 lab3 restlet url
  5. Press module4_lab3_send_button

    After doing click in the response, you will see the following response

    module4 lab3 restlet error response

    We have got a 500 response. There is an error in our flow.

    Let’s go back to the Flow Designer and see what happened

Step 3: Debug the Facebook Campaign API

  1. Open your project in Flow Designer

    module4 lab3 flow execution

    You can see a green line in many components of the flow. The green lines are steps that were executed in the flow. If you touch on any card, you can see the input and output.

  2. Open the Create Audience Card

    module4 lab3 open create audience
  3. Go to the Input tab

    module4 lab3 create audience input
  4. Go to the Output tab


    This step was executed without any error and is possible to see the input and output.

    Now let’s see the logs

  5. Go to the Menu and select Open Logs

    module4 lab3 open logs menu

    On the bottom of the page you will see a panel showing the console logs

    module4 lab3 logging panel
  6. Scroll up and you will find an error similar to this

    Message               : org.mule.extension.http.api.request.validator.ResponseValidatorTypedException: HTTP POST on resource failed: bad request (400). (org.mule.runtime.core.exception.TypedException).
    Payload               : null
    Payload Type          : null
    Element               : create-campaign/processors/0 @ facebookcampaign-fb-sjhf:null:186
    Element XML           : <http:request config-ref="social-network-a-p-ifor-facebook-httpreq-config" path="/campaign" method="POST">
                            <http:body>#[output application/json --- parameters['create-campaign-request-data']]</http:body>
                            <http:headers>#[ { 'Content-Type': parameters['content_-type'],'Accept': parameters['accept'] } filter $ != null]</http:headers>
                            <http:query-params>#[ { 'client_id': parameters['client-id'],'client_secret': parameters['client-secret'] } filter $ != null]</http:query-params>
    Root Exception stack trace:
    org.mule.runtime.api.exception.MuleRuntimeException: HTTP POST on resource failed: bad request (400).
    	at org.mule.runtime.extension.api.exception.ModuleException.<init>(
    	at org.mule.runtime.extension.api.exception.ModuleException.<init>(
    	at org.mule.extension.http.api.request.validator.ResponseValidatorTypedException.<init>(
    	at org.mule.extension.http.api.request.validator.ResponseValidatorTypedException.<init>(
    	at org.mule.extension.http.api.request.validator.RangeStatusCodeValidator.throwValidationException(
    	at org.mule.extension.http.api.request.validator.SuccessStatusCodeValidator.validate(
    	at org.mule.extension.http.internal.request.HttpRequester$1.lambda$onCompletion$1(

    The log is saying that the Create Campaign method is returning Bad Request Also you can see that the green line ends at that card.

Step 4: Fix the Request Message

At this point it seems to be obvious that we need to change the transform step that is before this card.

  1. Open the Transform card

    module4 lab3 open transformation
  2. Go to the script tab. We are going to add the name, startDate and endDate.

  3. Copy and paste the following text:

    %dw 2.0
    output application/json
      audience: [
      name: 'Mythical Workshop Campaign',
      startDate: '20170802',
      endDate: '20170815'
  4. Close module4_lab1_close_button card.

  5. Press Run button.

  6. Go back to the Rest Client that was opened in Chrome

  7. Press module4_lab3_send_button

    module4 lab3 restlet success response

    That is the Campaign ID of the Facebook Marketing campaign you’ve just deployed for your target Customer Audience.


In this lab, we:

  • Run the application

  • Test the Application

  • Debug the Facebook Campaign API

  • Fix the Request Message

We easily created and designed a Campaigns application for our social media marketing campaign, providing Sheryl with the ability to upload and correlate customer data to Facebook. We leveraged Flow Designer for an ad-hoc integration approach.

We saw how by abstracting our back-end systems as APIs, the line of business was able to reuse the Customer and Social Network APIs we created in other modules in a self-service way to create Process layer applications to streamline business processes.

Sheryl in Marketing is happy because she was able to get access to the data she needed for her initiative in a quick, self-service way, and Central IT is happy because they’re not provisioning any new assets, yet still maintaining governance of their underlying data.

Congratulations! You have completed Module 4.

Please proceed to Module 5