-
Created by
user-5ad4e, last updated by Unknown User (mgz29) on Apr 21, 2022
3 minute read
You are viewing an old version of this page. View the current version.
Compare with Current
View Page History
« Previous
Version 19
Next »
| URL | /api/login/ |
| Description | Login a user, and set cookie for authentication |
| Method | POST |
| Url Param |
|
| Request Body Data | - HTML Form Submission with fields:
- email (string)
- password (string)
- remember_me (optional boolean)
- Alternatively, you can manually add following fields in request body as a json format:
- email (string)
- password (string)
- remember_me (optional boolean)
- formdata (empty string)
|
| Response | - {message: "Logged in."} - 200
- {message: "Bad request format"} - 400
- {message: "invalid credential(s) provided, please check your credential(s) and try again"} - 400/401
|
| Cookie | - session: a cookie for trace login status
- remember_token: a cookie for remember_me feature (only when logged in with remember_me set to true)
|
| URL | /api/registration/ |
| Description | Register a new user. |
| Method | POST |
| Url Param |
|
| Request Body Data | - HTML Form Submission with fields:
- email (string)
- username (string)
- password (string)
- password2 (string)
- Alternatively, you can manually add following fields in request body as a json format:
- email (string)
- username (string)
- password (string)
- password2 (string)
- formdata (!EMPTY! string)
|
| Response | - {message: "Registered, please login."} - 200
- {message: "Data input is not valid, please try again"} - 400
|
| Cookie |
|
| URL | /api/logout/ |
| Description | Logout a user, set cookie/disable the token saved in cookie |
| Method | POST |
| Url Param |
|
| Request Body Data |
|
| Response | - {message: "logged out"} - 200
|
| Cookie | - session: will be removed
- remember_token: will be removed
|
| URL | /api/samples/ |
| Description | Add sample data to mongoDB |
| Method | POST |
| Url Param |
|
| Request Body Data | A json format data { "sample": { "description": "test", "image_url": "url", "uploader": "uploader", "sample_id": "0000", "sample_type": "BS", "infant_id": "00" } } |
| Response | - {message: "Sample data recorded!"} - 200
- {message: "Bad reques"} - 400
- {message: "invalid credential(s) provided, please check your credential(s) and try again"} - 400/401
|
| URL | /api/mobile-samples/ |
| Description | Get user's sample data from mobile database |
| Method | GET |
| Url Param |
|
|
|
| Response | - {message: "Internal Error, please try again"} - 500
|
| URL | /api/mobile-samples/image/<barcode_id> |
| Description | Get sample image to mongoDB |
| Method | GET |
| Url Param | barcode_id |
| Request Body Data |
|
| Response | - {message: "Bad barcode id"} -400
- {message: "Bad Request"} - 400
- {message: "No image data found for barcode {barcode_id}"} - 404
- {message: "No sample found for barcode {barcode_id}"} - 404
- image - 200
|
| URL | /api/samples/image/<barcode_id> |
| Description | Add sample image to mongoDB |
| Method | POST |
| Url Param | barcode_id |
| Request Body Data | files: { image: image } |
| Response | - {message: "Bad barcode id"} -400
- {message: "Bad Request"} - 400
- {message: "No sample found for barcode {barcode_id}"} - 404
- {message: "No image uploaded, bad request"} - 400
- {message: "image saved"} - 200
|
| URL | /api/samples/surey/<barcode_id> |
| Description | Get sample image to mongoDB |
| Method | GET |
| Url Param | barcode_id |
| Request Body Data | { data: survey } |
| Response | - {message: "Bad barcode id"} -400
- {message: "Bad Request"} - 400
- {message: "No sample found for barcode {barcode_id}"} - 404
- {message: "No survey found in request body"} - 400
- {message: "survey saved"} - 200
|
| URL | /api/samples/surey/<barcode_id> |
| Description | Add sample image to mongoDB |
| Method | POST |
| Url Param | barcode_id |
| Request Body Data |
|
| Response | - {message: "Bad barcode id"} -400
- {message: "Bad Request"} - 400
- {message: "No sample found for barcode {barcode_id}"} - 404
- {message: "No survey found for barcode {barcode_id}"} - 404
- survey_data - 200
|
| URL | /api/infant/ |
| Description | Add infant to db |
| Method | POST |
| Url Param |
|
| Request Body Data | HTML Form Submission with fields:- description (string)
- infant_id (string)
- name (string)
|
| Response | |
| URL | /api/infant/<id> |
| Description | Get infant by id |
| Method | GET |
| Url Param | infant_id |
| Request Body Data |
|
| Response | - {message: "Infant does not exist"} -404
{ 'infant_id': infant.infant_id, 'name': infant.name, 'create_time': infant.create_time, 'description': infant.description }, 200
|
| URL | /api/getSurvey/<surveyId> |
| Description | Get Survey CSV data by surveyId |
| Method | GET |
| Url Param | surveyId |
| Request Body Data |
|
| Response | - {statusCode: 200, data: {"csv data..."}} -200
|