MUFundamentals3.9 Studentmanual Mod01 Mod02
MUFundamentals3.9 Studentmanual Mod01 Mod02
MUFundamentals3.9 Studentmanual Mod01 Mod02
13
Walkthrough 1-1: Explore an API directory and an API reference
In this walkthrough, you make calls to a RESTful API. You will:
14
3. Browse the list of popular APIs.
Note: If Twitter is no longer displayed on the main page, search for it.
15
5. In the Specs section, click the API Portal / Home Page link.
6. In the new browser tab that opens, click Tweets in the left-side navigation.
7. In the left-side navigation, click Post, retrieve and engage with Tweets.
16
10. Review the information for POST statuses/update including parameters, example request, and
example response.
17
Walkthrough 1-2: Make calls to an API
In this walkthrough, you make calls to a RESTful API. You will:
18
6. Click the Send button; you should get a response.
7. Locate and click the return HTTP status code of 200.
8. Review the response body containing flights to SFO, LAX, and CLE.
19
12. Click the X next to the parameter to delete it.
13. Change the request URL to use a uri parameter to retrieve the flight with an ID of 3:
http://training-american-ws.cloudhub.io/api/flights/3
14. Click the Send button; you should see only the flight with that ID returned.
Note: The database is not actually modified so that its data integrity can be retained for class.
20
18. Click the Send button; you should get a 405 response with a message of method not allowed.
21
27. Return to Postman and paste the code in the body text area.
28. Click the Send button; you should see a 201 response with the message Flight added (but not
really).
29. Return to the request body and remove the plane field and value from the request body.
30. Remove the comma after the emptySeats key/value pair.
31. Send the request; the message should still post successfully.
22
32. In the request body, remove the emptySeats key/value pair.
33. Delete the comma after the destination key/value pair.
34. Send the request; you should see a 400 response with the message Bad request.
23
39. Send the request; you should see the response Flight updated (but not really).
Note: The -ws in the URL has been changed to -api and the /api removed.
42. Click the Send button; you should get a message about a missing client_id.
43. Return to the course snippets.txt file and copy the value for the American Flights API client_id.
44. Return to Postman and add a request parameter called client_id.
45. Set client_id to the value you copied from the snippets.txt file.
46. Return to the course snippets.txt file and copy the value for the American Flights API
client_secret.
47. Return to Postman and add a request parameter called client_secret.
24
48. Set client_secret to the value you copied from the snippets.txt file.
49. Click the Send button; you should get data for flight 3 again.
Note: The API service level agreement (SLA) for the application with this client ID and secret
has been set to allow three API calls per minute.
50. Click the Send button three more times; you should get a 429 response and an API calls
exceeded message.
Note: The API service level agreement (SLA) for the application with this client ID and secret
has been set to allow three API calls per minute.
25
Module 2: Introducing Anypoint
Platform
26
Walkthrough 2-1: Explore Anypoint Platform and Anypoint
Exchange
In this walkthrough, you get familiar with the Anypoint Platform web application. You will:
Note: If you closed the browser window or logged out, return to https://anypoint.mulesoft.com
and log in.
2. Click the menu button located in the upper-left in the main menu bar.
27
3. In the menu that appears, select Anypoint Platform; this will return you to the home page.
Note: This will be called the main menu from now on.
28
10. In the left-side navigation, click MuleSoft; you should see all the content in the public Exchange.
11. In the left-side navigation, click the name of your organization beneath MuleSoft (Training in the
screenshots); you should now see only the content in your private Exchange, which is currently
empty.
29
14. Click one of the connectors and review its information.
15. In the left-side navigation, click the Assets list link.
16. Select the Salesforce connector (or search for it if it is not shown) and review its details.
30
Discover and review the API portal for the Training: American Flights API
21. Locate and click the Training: American Flights API.
23. In the left-side navigation, expand and review the list of available resources.
24. Click the GET link for the /flights resource.
31
25. On the /flights: Get all flights page, review the information for the optional query parameter.
26. Scroll down and locate the type and details for the data returned from a call.
32
27. Select the Examples tab; you should see an example response.
Use the API console to make calls to the Training: American Flights API
28. Scroll up and locate the API console on the right-side on the page.
29. Select to show optional query parameters and select a value.
30. Select a destination and click Send; you should get the example data returned using the
mocking service.
31. In the API console, change the API instance from Mocking Service to RAML Base URI.
33
32. Click Send again; you should get results from the actual API implementation for the destination
you selected.
34
Walkthrough 2-2: Create a Mule application with flow designer
In this walkthrough, you build, run, and test a basic Mule application with flow designer. You will:
4. In the New Mule Application dialog box, set the project name to American Flights App.
35
5. Click Create; flow designer should open.
8. In the Design Center project list, click the row containing the American Flights App; you should
see information about the project displayed on the right side of the page.
36
9. Click the Open button or click the American Flights App link in the project list; the project should
open in flow designer.
37
14. In the Trigger card, select HTTP Listener.
15. In the HTTP Listener dialog box, set the path to flights.
16. Click the Edit link for the CloudHub HTTP configuration.
17. In the HTTP Listener Configuration dialog box, review the information and click Cancel.
38
18. In the HTTP Listener dialog box, click the close button in the upper-right corner.
Add a Logger
19. Click the add button next to the HTTP Listener card.
39
21. In the Logger dialog box, set the message to test.
25. Locate the application status in the main menu bar; it should say Ready to deploy.
40
26. Look at the generated URL for the application.
Note: The application name is appended with a four-letter suffix to guarantee that it is unique
across all applications on CloudHub.
Note: If your application fails to deploy, look at the messages in the Logs panel. If there is no
message about incorrect syntax, try restarting the workspace by clicking the options menu in the
application status area and selecting Restart workspace.
29. Click the options menu in the application status area and select Copy link.
31. Add /flights to the path and click Send; you should get a 200 response with no body.
41
32. Click Send again to make a second request.
33. Return to flow designer.
34. Notice that there are now green lines across both cards.
35. Look at the logs; you should see your Logger message displayed twice.
42
37. In the new browser tab that opens with Runtime Manager, review the application log file; you
should see your test log messages.
43
Walkthrough 2-3: Create an integration application with flow
designer that consumes an API
In this walkthrough, you build an integration application to consume an API from Anypoint Exchange.
You will:
44
6. Locate your two calls to the application in the History panel; there should be no message
payload for either call.
7. Change the Show drop-down menu to Attributes.
8. Review the attributes for the Mule event leaving the HTTP Listener processor.
13. Click the Output tab and review the payload and attributes values for the calls.
45
Delete a card
14. Click the Remove button at the top of the card.
Use the American Flights API in Anypoint Exchange to get all flights
15. Click the Add button next to the HTTP Listener card.
16. In the Select a component dialog box, select the American Flights API.
17. In the American Flights API > Select an operation dialog box, select Get All Flights.
46
18. In the Get All Flights dialog box, click the Edit link for the American Flights API configuration.
47
Test the application
22. Return to Postman and click Send; you should see flight data.
48
Add and configure a component to transform the data
28. Click the add button in the flow.
29. In the Select a component dialog box, select Transform.
30. In the Transform card, look at the Mule event structure in the input section.
31. In the output section, click the Create new Data Type button.
49
32. In the New Type dialog box, set the following values:
• Name: Flights
• Format: JSON
• Type: From example
33. In the computer's file explorer, return to the student files folder and locate the flights-
example.json file in the examples folder.
34. Open the file in a text editor and copy the code.
35. Return to flow designer and paste the code in the section to add your JSON example.
50
37. In the input section, expand the plane object.
51
Create the transformation
38. Map fields with the same names by dragging them from the input section and dropping them on
the corresponding field in the output section.
• price to price
• departureDate to departureDate
• plane > totalSeats to totalSeats
• emptySeats to emptySeats
52
39. Map fields with different names by dragging them from the input section and dropping them on
the corresponding field in the output section.
40. In the output section, click the options menu for the airline field and select Set Expression.
53
41. Change the value from null to "american" and click OK.
42. Click the Script tab at the bottom of the card; you should see the DataWeave expression for the
transformation.
Note: You learn to write DataWeave 1.0 expressions later in this course. You can also learn to
write DataWeave expressions in the Flow Design course and the DataWeave course.
54
45. Open the file in a text editor and copy the code.
46. Return to flow designer and paste the code in the sample data for payload section.
47. Look at the preview section, you should see a sample response for the transformation.
48. Close the card.
55
Locate the data type and configuration definitions
49. Locate the connector configurations and the new Flight data type in the project explorer.
56
54. Select the row with your application; you should see information about the application displayed
on the right side of the window.
55. Click the drop-down menu button next to Started and select Stop; the status should change to
Undeployed.
Note: You can deploy it again from flow designer when or if you work on the application again.
57