Skip to content

Fix PUT and DELETE APIs and add error handling, logging and configuration #259

Maria Kalusz edited this page Mar 25, 2020 · 10 revisions

Resources

 https://docs.microsoft.com/en-us/azure/azure-functions/functions-reference-python
 https://docs.microsoft.com/en-us/azure/azure-functions/functions-host-json
 https://docs.microsoft.com/en-us/azure/azure-functions/functions-monitoring
 https://docs.microsoft.com/en-us/azure/azure-functions/functions-bindings-http-webhook-trigger?tabs=python
 https://github.com/mkleehammer/pyodbc/wiki/Exceptions
 https://www.python.org/dev/peps/pep-0249/#exceptions
 https://thepythonguru.com/handling-errors/

DELETE API

Prerequisites

  • For the initial setup of Delete machine api, follow the wiki below.

        https://github.com/North-Seattle-College/ad440-winter2020-tuesday-repo/wiki/API-DELETE-machines-%7Bid%7D
    

Testing

Function URL

 https://maria-fun-usw2-task141.azurewebsites.net/api/v1/machines/{MachineID}

Sample Test

  • Enter the function URL into Postman and add a MachineID at the end of the URL in place of {MachineID}. Change the method to a DELETE request, then press Send. You should see a Response to the request below.

PUT API

Prerequisites

  • For the initial setup of Put machine api, follow the wiki below.

        https://github.com/North-Seattle-College/ad440-winter2020-tuesday-repo/wiki/API-PUT
        https://github.com/North-Seattle-College/ad440-winter2020-tuesday-repo/wiki/PUT-machines-%7Bid%7D-updates-the-machine-in-DB,-read-SQL-connection-string
    

Testing

Function URL

 https://jos-rg-fun-usw2-task62.azurewebsites.net/api/v1/machines

Sample Test

  • In order to update a machine, enter the function URL into Postman and change the method to a PUT request. Enter the JSON data sample below into the body section of Postman. Press Send. You should then see a Response to the request below.

     {
         "MachineID": 126,
         "Model": "Encore",
         "ModelNum": "24",
         "SerialNum": "43543-432",
         "VendorID": 0,
         "LocationID": 1010,
         "ModelPhoto": "None",
         "Status": "yellow",
         "StatusDescription": "filter due to replacement"
     }
    
Clone this wiki locally