Skip to main content

Perform API Calls

Learning Objectives

After completing this unit, you’ll be able to:

  • Understand how to use a REST client to execute API calls.
  • Distinguish between GET and POST requests.
  • Analyze API responses, including HTTP status codes and headers.

In earlier units, you explored how APIs connect systems, enable secure integrations, and use HTTP methods like GET and POST. You also saw how Mule United Airport leveraged APIs to improve operations and deliver real-time updates to passengers.

This unit builds on that foundation by showing you how to interact directly with APIs using tools like REST clients. You will be using an interactive Trailhead Simulator that lets you practice making API calls and analyzing responses in a guided environment.

Work with REST Clients

When working with APIs, developers need efficient ways to test and debug requests. Instead of writing code for every interaction, they use tools called REST clients, which provide user-friendly interfaces for interacting with REST APIs.

A woman faces a choice between a confusing maze labeled ’Manual API Testing’ and a clear open door labeled ’REST Client’.

A smiling woman walks confidently toward a large sign pointing to ’REST Client’.

What Are REST Clients?

REST clients, like Postman and Advanced REST Client (ARC), are essential tools for making API calls and analyzing responses. These tools help developers by:

  • Simplifying Requests: Compose and send requests without writing code.
  • Supporting HTTP Methods: Work with GET, POST, PUT, DELETE, and PATCH.
  • Customizing Headers and Parameters: Include authentication tokens, query parameters, and other essential details.
  • Interpreting Responses: View HTTP status codes, headers, and payloads in a readable format.

Why Use REST Clients?

REST clients help with several tasks.

  • Testing APIs: Ensure endpoints work as expected before incorporating them into applications.
  • Troubleshooting Issues: Identify errors by examining status codes or payload details.
  • Learning APIs: Explore an unfamiliar API’s behavior and documentation interactively.

Using a REST client saves time, enabling developers to focus on designing solutions rather than debugging request code.

Explore an API Using MuleSoft’s Training Portal

Now that you understand how APIs enable applications to exchange data, let’s take a closer look at how an API is structured and how it communicates. In this walkthrough, you’ll explore a real API portal to see how endpoints, methods, and responses are documented.

You won’t need to install any tools or write code, just follow along using your browser.

Access the Developer Training Portal

You’ve just joined the team at Mule United Airport. Your job is to explore the American Flights API and learn how to retrieve flight schedules and manage bookings using REST methods like GET and POST.

  1. Open a browser and go to https://anypoint.mulesoft.com/exchange/portals/muletraining/.
  2. Click Training: American Flights API to open its API portal.
  3. In the left-side navigation, click /flights to view its available methods.
  4. Click /{ID} to see the endpoint details for individual flights.
  5. Select the GET method under /flights
    1. You will see there is an available query parameter: destination.
    2. Scroll down the page to view the Headers and Responses sections.
  6. In the navigation panel, select the DELETE method for /flights/{ID}.
    1. Note the ID URI parameter is a string and is required.
    2. To test this endpoint, enter 3 as the value for the ID field. This will simulate deleting the flight with ID 3.
  7. Browse the rest of the available resources to see how different operations are supported.
Note

In a real-world scenario, you'd use the GET method first to retrieve a list of flights, then choose one of the IDs returned. For now, use 3 as a known working example.

Try It Yourself: Make API Requests in the Anypoint Platform

Now that you’ve familiarized yourself with the structure and documentation of the American Flights API, it’s time to get hands-on. In this section, you’ll send real requests through the API Console built into Anypoint Exchange and observe how the API responds.

Step 1: Send a GET Request

  1. Stay in the Training: American Flights API portal and select the /flights GET method again.
  2. In the API Console located on the right side, locate the Select server field and select Rate limiting SLA based policy from the drop-down menu.
  3. In the Headers section, add the following required values:
    1. client_id: c05ddced9f1442a5b4f46335b810f2f1
    2. client_secret:
      D86c96AC942346Ccb51D50B00ED5a4B4
  4. (Optional) In the Query Parameters section, select one of the drop down codes for destination, or leave it blank to return all flights.
  5. Click Send.

Review the response:

  • Confirm the status code is 200 OK
  • Look at the JSON body to see the returned flight information
    • If you didn’t set a destination, you should see 11 flights returned.
    • If you selected LAX or CLE, you should see 3 flights.
    • If you selected SFO, you should see 5 flights.

Step 2: Submit a POST Request

  1. In the API Console, select the /flights POST method.
  2. Re-enter the required client_id and client_secret values from Step1.
  3. The console includes a sample request body to show you the expected format. Take a moment to review it, then replace or modify the values to create a new flight of your own.
{
  "code": "GQ574",
  "price": 399,
  "departureDate": "2016/12/20",
  "origin": "ORD",
  "destination": "SFO",
  "emptySeats": 200,
  "plane": {
    "type": "Boeing 747",
    "totalSeats": 400
  }
}
  1. When you're ready, click Send to submit the request and check the response.
  2. Look for a 201 Created response.
Note

Before you test error scenarios, make sure the Select server field in the API Console is set to Rate limiting SLA based policy.

By default, the API Console uses Mocking Service, which always returns example success responses—even if you leave out required credentials like client_id or client_secret. When Mocking Service is selected, you’ll see a 201 Created status even if your request is incomplete or incorrect.

To see real error codes—such as 401 Unauthorized when authentication information is missing—you must switch the server to Rate limiting SLA based policy. This ensures you’re sending live requests to the training API, not mock responses.

You’ll learn more about the Mocking Service and how to use it in Module 3.

Step 3: Trigger and Analyze Errors

Now let’s see what happens when something goes wrong. APIs respond with different status codes depending on the problem. Testing these responses helps you understand how to debug and handle errors, which is something every API developer needs to know.

Try the following scenarios using the POST /flights method:

Missing Required Data

  • In the Body, remove a required field like "code" or "origin".
  • Click Send.
  • You should receive a 400 Bad Request response, indicating the API couldn’t process the request.

Missing Headers

  • Try removing the client_id or client_secret from the Headers.
  • Send the request again.
  • You’ll see a 401 Unauthorized error, which means the request didn’t include valid credentials.

Each of these errors tells a story. Check the status code, response body, and headers—just like you would when diagnosing an issue in a real integration.

Note

Because this training API simulates successful POST responses, you may still see a 201 Created status even if you omit credentials. In a real-world API, missing required authentication would return a 401 Unauthorized error.

Understand Why This Matters

Now you’ve explored how to read API documentation, send real GET and POST requests, and interpret responses like a developer would. You also got a look at common errors and how to troubleshoot them.

These are the building blocks of working with APIs. They help you understand how systems exchange data and what to look for when something goes wrong.

You’ve also seen how organizations like Mule United Airport use APIs to connect systems and deliver better, faster services. Replacing outdated, siloed tools with connected APIs creates more flexibility and a better experience for users.

This practice sets you up for the next step, learning how to design your own APIs with confidence.

Comparta sus comentarios de Trailhead en la Ayuda de Salesforce.

Nos encantaría saber más sobre su experiencia con Trailhead. Ahora puede acceder al nuevo formulario de comentarios en cualquier momento en el sitio de Ayuda de Salesforce.

Más información Continuar a Compartir comentarios