Suivez votre progression
Accueil Trailhead
Accueil Trailhead
Durée estimée

Use Orders API for Submitting Orders

You’ve configured your flow to obtain opportunity information from Salesforce and product information from the database. This information is needed for placing orders within NTO’s order management system. Luckily, the IT team at NTO has created an Orders API to make interacting with Orders simple. Before this information is used to place an order, it needs to be formatted in a way that the API is expecting. Once the data is in the correct format, a POST request can be made to the API, which returns the OrderID, tracking, and ETA for the order that was placed. 

Use the Transform component to format the payload and make the API call using the request module.

  1. Click the right arrow to the right of the Choice router block and add a Transform component.
  2. Add another card on the right side of the Transform card. Select the HTTP Request module and add these details:
    • Method: POST
    • URL (this is the URL for NTO’s Order API):
      https://anypoint.mulesoft.com/mocking/api/v1/sources/exchange/assets/org.mule.examples/quick-start-nto-orders-api/1.0.0/m/orders
  3. Close the Request card and open the Transform card to its left.
  4. Set the data types for the values on the left side.
    • Click card options next to payload in the input column
    • Select Set
    • Select the Product Information data type
  5. Repeat step 4 for OppDetails under vars and set the data type to Salesforce Opportunity.
  6. Repeat step 4 for payload on the right-hand side and set the data type to Order Information. The Transform card should look like this:
    The transform card is expanded. You see the input fields on the left side and the output fields in the right side. The interface is suggesting that you can drag fields to map them.
  7. Drag elements from the left side to the right side based on these mappings:
Input field
Output field
productID
productID
category
category
SKU
SKU
productName
productName
inventory
inventory
Amount
OrderAmount
CloseDate
orderdate
Id
OppId

8. If you see an Output media type differs from expected one error, click the Fix It button to resolve. The final Transform card should look like this:

The transform card is expanded. There are black lines joining the input fields on the left side to the output fields on the right side indicating the field mappings.

Now you’re ready to place orders! The payload shown in the preview will be posted onto the NTO Orders API. In return, the API will respond with order tracking information. We discussed earlier how customers often call the NTO offices to ask for the status for their orders. To streamline this process for NTO, you’re going to automate sending of order details to customers via SMS. In the next step, you will use the Twilio connector to send SMS notifications to customer upon placing orders.

We won’t check any of your setup. Click Verify Step to go to the next step in the project.