Skip to main content
New Hire Training

Call an API


  1. Go to your Mendix app. Left click on “Main” on the left side, then click “Add microflow…”. Name it “REST_Call”, then click “OK”.
  2. Drag a “Microflow call” from the Toolbox onto your flow.

    NewHireImage4

  3. Double-click on the “Call microflow” box, click “Select…”, then search for “ACT_ClientToken_GetToken”. This is a microflow included in the BYU starter app that generates an API token. Select this microflow, then click “OK”.
  4. Drag a “Call REST service” from the Toolbox onto your flow.

    NewHire

  5. In a browser, go to developer.byu.edu/api-search.
  6. Search for Persons v3 and open the API documentation.
  7. Scroll down until you find the API that takes in a BYU ID.

    NewHireImage6

  8. Click "GET", then copy the URL shown.
  9. In your Mendix app, in the REST_Call microflow, double click on the “Call REST (GET)” item. Next to “Location”, click “Edit…”. Paste the API URL and replace “{byu_id}” with your BYU ID. If there is no “v3” in the URL, make sure to add it so it looks like this.

    NewHireImage7

  10. Click "OK", then open the "HTTP Headers" tab. Create a new Custom HTTP Header.
  11. Enter "Authorization" for the key and "$ClientToken/Token" for the value.

    NewHireImage8

  12. Click “OK”, then “OK” again to exit the popups.
  13. Go back to BYU Developer Portal. On the right side, copy the JSON structure for the API.

    NewHireImage9

  14. In Mendix, right click on Main, then click on Add other > JSON structure. Name it “Persons_Structure”.
  15. Delete the empty braces and paste the JSON structure we copied from the developer portal.
  16. Under "Structure", click "Refresh"

    NewHireImage10

  17. Click "OK".
  18. Right-click on Main, then click on Add other > Import mapping. Name it “Persons_Mapping”.
  19. Select “JSON structure”, then select “Persons_Structure”.
  20. Under “Schema elements”, uncheck “(Object)”, then select “first_name” and “value” under "basic". Click "OK"

    NewHireImage11

  21. Click “Map automatically…” at the top of the screen.
  22. Open your “REST_Call” microflow and open the “Call REST (GET)” widget.
  23. Open the “Response” tab. Set “Response handling” to “Apply import mapping”.
  24. Set the import mapping to “Persons_Mapping”. Select “Yes” under “Store in variable” and change the variable name to “FirstName”. It should look like this.

    NewHireImage12

  25. Open the end event of your microflow.
  26. Change the return type to “Object”
  27. Set the entity to “Main.First_name”
  28. Set the return value to $FirstName. Click “OK”. Your final microflow should look like this.

    NewHireImage13

Previous Topic
Configure API settings
Next Topic
Display data on your page
Was this topic helpful?
Thanks for your feedback.