Skip to content

Fix GET and POST APIs and add error handling, logging and configuration #260

hken920 edited this page Mar 24, 2020 · 3 revisions

https://github.com/North-Seattle-College/ad440-winter2020-tuesday-repo/issues/260

Prerequisites:

Install Postman

IoT Hub resource


POST REQUEST TEST:

Step 1: Open Postman and start new tab

  • In Postman click "+" tab to start a new tab
  • Select POST in drop down menu to the left of parameter field

Step 2: Paste URL into Postman

* https://ken-fun-feat-usw2-task60.azurewebsites.net/api/v1/machines

Step 3: Write test JSON file in Postman

  • Click Body tab under URL field
  • Select raw option located under "Body" tab
  • In the orange drop down bar located to the right of "GraphQL" change text to JSON
  • Write test code in the body of JSON following this format
    • { "Model":"_string_", "ModelNum":"_string_", "ModelPhoto": null, "SerialNum":"_string_", "VendorID":0, "LocationID":1010 }

Step 4: Select request and send

  • Select POST request and click Send

Step 5: Navigate to Function app to check logs

  • Sign in Azure portal > Resource Groups > ken-rg-feat-usw2-task60 > Function app resource (ken-fun-feat-usw2-task60) > Monitor

GET MACHINES TEST:

Step 1: Open Postman program

Step 2: Go to File > New > Request

Step 3: Change drop down to GET

Step 4: Make sure Params is selected

Step 5: Paste the Azure Function App URL `https://kiara-fun-feat-usw2-task155.azurewebsites.net/api/v1/machines in text box next to GET button

Step 6: Click the green Send button and you will see the data from the machines table in JSON format.

Step 7: Log into your Azure portal

Step 8: Click on Resource Groups and search for Kiara-rg-fun-usw2-task155

Step 9: Click on Kiara-rg-fun-usw2-task155 resource group

Step 10: On the left hand side click on Monitor

Step 11: Click on the most recent test to see the Invocation Details and you will see the logging messages.


GET MACHINE ID TEST:

1: Open Postman program

2: Make sure drop down is set to GET

3: Make sure Params is selected

4: Paste the Azure Function App URL https://san-fun-usw2-task156.azurewebsites.net/api/v1/machines/{MachineID} in text box next to GET button

5: Where {MachineID} is, enter a machine id number

6: Click the green Send button and you will see the data from the machines table in JSON format.

7: Log into your Azure portal

8: Click on Resource Groups and search for san-rg-feat-usw2-task156

9: Click on san-rg-fun-usw2-task156 resource group

10: On the left hand side click on Monitor

11: Click on the most recent test to see the Invocation Details and you will see the logging messages

Clone this wiki locally