Lab 3: Deploy and Run the Campaigns Flow


Continuing on from Lab 2, let’s test our new flow end-end and examine the various capabilities that Flow Designer provides.

Step 1: Test the application

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

  1. Click the Test Button situated on the right top part of the screen.

    module4 lab3 run button
  2. Once you click on the Test button, the message will change to Preparing for test

    module4 lab3 run button starting
  3. Finally you will see the message Running in a temporary environment

    module4 lab3 latest changes deployed

Step 2: Test the Application

  1. Clicking on the three dots to the right of the Test button will cause a Menu to be displayed

    module4 lab3 display menu

    We will give a description of each item

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

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

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

    • Export application: Export the application as as jar file.

  2. Click on the three dots to the right of the Test button again to close the Menu

    module4 lab3 close menu
  3. We need to know the URL of the API we are going to test, so we will click on the name of the API. This copies the URL to the clipboard.

    module4 lab3 copy url
    You can use Postman or any other REST Client. If you are unable to install a Chrome extension, try using a web-based tester like API Tester (
  4. If you DO NOT have the Restlet Client API Tester installed, skip to step 7.

  5. Otherwise, open the Chrome browser and open the Restlet Client extension.

    module4 lab3 restlet client
  6. Paste the URL you just copied and append /campaigns to the URL

    module4 lab3 restlet url
  7. Press module4_lab3_send_button

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

    module4 lab3 restlet error response
  8. If DO NOT have the Restlet Client API Tester installed, open the Chrome browser and go to API Tester (

  9. Paste the URL you just copied and append /campaigns to the URL

  10. Press the Test button.

    module4 lab3 apitester restlet client
  11. Ensure 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. Return to your project in Flow Designer

    module4 lab3 flow execution

    You can see a green circle with a 'tick' in many components of the flow. The green circles are steps that were successfully executed in the flow. There is one card that has a red circle with a '!', this means an error occurred. 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


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

    Now let’s see the logs

  5. Go to the Menu and select View logs

    module4 lab3 view runtime mgr menu

    A new window will open at the bottom of the flow with the logging information.

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

    Message               : HTTP POST on resource '' failed: bad request (400).
    Element               : new_flow/processors/1/route/0/processors/4 @ mythicaluserfacebookcampaign-lkhm:mule-config.xml:54 (Create Campaign)
    Element XML           : <social-network-ap-ifor-facebook:create-campaign client-id="11def1b704e24d87a5ea5769772c90a7" client-secret="88845E529f1F42E4a5aC96Fd504c3e01" config-ref="social_network_api_for_facebook" doc:id="358907a7-c7c3-4491-a535-7527605fe209" doc:name="Create Campaign" doc:timestamp="1564373789423"></social-network-ap-ifor-facebook:create-campaign>
    FlowStack             : at social-network-ap-ifor-facebook:create-campaign 76 ms
                            at new_flow(new_flow/processors/1/route/0/processors/4 @ mythicaluserfacebookcampaign-lkhm:mule-config.xml:54 (Create Campaign)) 77 ms
    Payload               : null
    Payload Type          : null
    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.lambda$throwValidationException$3(

    The log is saying that the Create Campaign method is returning Bad Request Also you can see that the green circles end at that card and there is a red circle instead.

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.

    module4 lab3 transformation script tab
  3. Copy and paste the following text:

    %dw 2.0
    output application/json
      audience: [
      name: 'Mythical Workshop Campaign',
      startDate: '20170802',
      endDate: '20170815'
  4. You will see the following after pasting in the new script:

    module4 lab3 transformation script paste
  5. Close module4_lab1_close_button card.

  6. Press the Test button.

    module4 lab3 run button
  7. You should see the status change to Preparing for test.

    module4 lab3 run button starting
  8. Wait until you see the message Running in a temporary environment.

    module4 lab3 latest changes deployed
  9. Go back to the Rest Client that was opened in Chrome (or Postman/REST API Tester)

  10. 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:

  • Tested using a REST client

  • Tested our Application

  • Debugged the Facebook Campaign API

  • Fixed 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