Exercise: Connect a database in Node-Red
Install CURL
First we need to install the curl application:$ sudo apt install curl
Write a service that reads a GET token
Wirte a service, that needs as input a token "securetoken" and verifies the value. The value must be "fkjdkfd2288". If the token is OK. Then the service returns a JSON list of all the patients. If the token is not OK, it returns an empty list.SOLUTION
You can download the flow from: solutionGET.jsonThis works on the URLs : http://localhost:1880/test_json_secure2?securetoken=fkjdkfd2288 and http://localhost:1880/testSecure?securetoken=fkjdkfd2288.
Write a service that reads a POST token
Write a service, that reads from the POST method the following JSON:{ "securetoken":"fkjdkfd2288", "patient": 1 }If the token is valid and the patient id also, then you return a JSON containing the data of this patient.
SOLUTION
You can download the flow from: solutionGetPost.jsonTo test, use the following CURL command:
curl -X POST -d'{"securetoken":"fkjdkfd2288", "patient":1}' -H "Content-type: application/json" http://localhost:1880/readtoken
Related Pages
Contact
Prof. Dr. Emmanuel Benoist
Berner Fachhochschule - TI
Quellgasse 21
CH-2501 Biel/Bienne
Switzerland
Mail: emmanuel.benoist (at) bfh.ch
Berner Fachhochschule - TI
Quellgasse 21
CH-2501 Biel/Bienne
Switzerland
Mail: emmanuel.benoist (at) bfh.ch
Social Networks
Follow
me
on
Linkedin, Scholar
& Research gate