To Dynamically Change the URL of a Request (Design Center)

This procedure builds on the procedure to create a basic Mule app. In that app, you requested data from a particular URL of a REST service. Now, you change the app to make a request to the URL you specify on-the-fly when you start the app. You configure the HTTP Request path using an expression. In the expression, you use the keyword from the query string that starts the app from a browser:



  • getpath is the value of Path in the listener configuration.

  • users is the path known to the JSON Placeholder service that returns user data.

  • <keyword> is configured a path for example.

    query params path
    1. Open myproject, and in the Consume API flow, open HTTP Request.

      change http request configuration
    2. Click Change to change the configuration of HTTP Request.

      • In General, in Path, click Function f of x key.

      • Type the following text:


        Pause to see a list of options.

        list of available options for entry
      • Select queryParams, and then type a period followed by this keyword:


        For example:


        attributes queryParams path
    3. Click Run, and execute the flow:

      • Click options run app design env design center 2428b > Copy Link.

      • Paste the link in a browser or client, and add the following path to the end of the link:


        The HTTP Listener hears the request, and starts the app. The list of todos appears in the browser.

            "userId": 1,
            "id": 1,
            "title": "delectus aut autem",
            "completed": false
            "userId": 1,
            "id": 2,
            "title": "quis ut nam facilis et officia qui",
            "completed": false
    4. Close HTTP Request.

      Green status indicators appear in all parts of the flow.

    5. Change the path of the URL to get the users.


          "id": 1,
          "name": "Leanne Graham",
          "username": "Bret",
          "email": "",
          "address": {
            "street": "Kulas Light",
            "suite": "Apt. 556",
            "city": "Gwenborough",
            "zipcode": "92998-3874",
            "geo": {
              "lat": "-37.3159",
              "lng": "81.1496"
    6. Change the URL to get the posts.


      Now, you’re ready to inspect input and output payloads and attributes.

In this topic: