Contact Us 1-800-596-4880

Lab 2: Test Published Document Action using Postman (Optional)

Overview

In this lab, you will use Postman to consume the document action created in Lab 1: Process an Invoice with MuleSoft IDP to process the Mythical’s invoices.

Prerequisites

If you didn’t complete Lab 1: Process an Invoice with MuleSoft IDP, you have two options to test the Mythical Invoice Document Action:

  • Use the document action published by another workshop attendee.

  • Quickly create a new <your-initials> - Mythical Invoice document action (leave everything set to the default) and publish it to Exchange.

Step 1: Create Postman Collection and Configure the Authentication

  1. Locate the Postman shortcut on the Windows desktop and open it (dismiss any pop-up and click "Skip and go to the app" if prompted for sign in/sign up" ):

    module g  postman shortcut
  2. Click the "Create new collection" button in the top-left corner of the window.

    module g  postman create coll btn
  3. Name the new collection MuleSoft IDP (close the documentation section on the right if open).

    module g  postman new collection name
  4. You should now be on the Postman Authorization tab.

    module g  postman auth tab
  5. Set the authorization type to OAuth 2.0

    module g  postman coll auth type
  6. Click the "Edit token configuration" button.

    module g  postman edit tok conf btn
  7. Set the "Configuration Options" as follows:

    Field Value

    Grant Type

    Client Credentials

    Access Token URL

    https://anypoint.mulesoft.com/accounts/api/v2/oauth2/token

    Client ID

    <The Client ID provided by the Workshop Instructor>

    Client Secret

    <The Client Secret provided by the Workshop Instructor>

    module g  postman auth conf options

    The Access Token URL can be found in Exchange in the Security section for the published Document Action.

    module g  doc act security
  8. Click the "Get New Access Token" button.

    module g  postman get new token btn
  9. In a few second you should get a message confirming that the authentication is completed, wait for the pop-up to disappear automatically.

    module g  postman auth complete
  10. When you are prompted with the generated token, then click the "Use Token" button.

    module g  postman use token popup
  11. Now you should see the Access Token set in the "Authorization" tab’s "Current Token" section.

    module g  postman current token
  12. Save the collection by clicking the "Save" button.

    module g  postman save coll btn

Step 2: Test POST method

  1. Locate the asset you want to test in exchange.

    module g  exchange assets
  2. Open the asset, expand the Endpoints in the left-side panel and click on the POST rectangle.

    module g  doc act endpoints post
  3. Copy the POST url from the center of the page, you are going to need it in Postman.

    module g  doc act post url
  4. In Postman expand the collection menu and click the "Add request" menu item. A new request tab should open.

    module g  postman add req to coll
  5. In the created tab, name the new request POST Mythical Invoice.

  6. Change the method to POST and enter the POST Request URL you just copied from Exchange.

    module g  postman post url
  7. Click on the "Headers" tab.

    module g  postman headers tab
  8. If not visible, click the button to show the hidden auto-generated headers.

    module g  postman show hidden
  9. You should see the "Authorization" header automatically added to the request

    module g  postman auth header
  10. Click on the "Body" tab.

    module g  postman body tab
  11. Select form-data as body type and configure it as follows:

    Key Type Value

    file

    File

    <Select the Mythical Invoice from the desktop>

    module g  postman post body
  12. The Mythical Invoice can be found here

  13. Click "Save" to save the request

    module g  postman save req btn
  14. Click "Send" button to submit the request

    module g  postman send button
  15. You should get a response like the following.

    module g  postman post response
  16. Congrats! You just posted the Mythical Invoice to MuleSoft IDP. Take note of the returned execution ID, as you’ll need it when testing the GET method to retrieve the IDP output.

Step 3: Test GET method

  1. Locate the asset you want to test in exchange.

    module g  exchange assets
  2. Open the asset, expand the Endpoints in the left-side panel and click on the GET rectangle.

    module g  doc act endpoints get
  3. Copy the GET url from the center of the page, you are going to need it in Postman.

    module g  doc act get url
  4. In Postman expand the collection menu and click the "Add request menu" item. A new request tab should open.

    module g  postman add req to coll
  5. In the created tab, name the new request GET Mythical Invoice.

  6. Leave the method to GET and enter the GET Request URL you just copied from Exchange.

    module g  postman get url
  7. Replace "{executionId}" in the URL with the execution ID you obtained when testing the POST method in the previous step.

    module g  postman rep exe id
  8. Click "Save" to save the request

    module g  postman save req btn
  9. Click "Send" button to submit the request

    module g  postman send button
  10. You should get a response like the following. Check the body for the data extracted from the Mythical Invoice.

    module g  postman get response
  11. Congrats! You just retrieved the Mythical Invoice processing output from MuleSoft IDP. You are now ready to move to the next lab.