This article will guide you through generating and registering QR via BioStar 2 API.
For information on how to issue BioStar 2 QR through BioStar 2 Web UI, please refer to the article below:
[BioStar 2] How To Issue BioStar 2 QR in BioStar 2 SW
QR/Barcode is available to use as BioStar 2 user credential starting from BioStar v2.8.11.
Prerequisites
1) You must set ‘Email Setting’ in BioStar 2 and enable [QR] option.
a. BioStar 2 -> Settings -> Email Setting -> Complete SMTP Setting
For more information on how to set SMTP setting:
[BioStar 2] How to Configure SMTP and Test the Recipient Address
b. Enable [QR] option
2) (ONLY for 'BioStar 2 QR')
You must add 'email' field for user you want to register BioStar 2 QR to.
There are 4 steps required to register Mobile Access to your Users:
- Check if the QR already exists by the Card ID(QR Number) you’d like to use
- Create a QR with the Card ID(QR Number) you’d like to use
- Register the QR to a user
- (ONLY for 'BioStar 2 QR') Send the QR to the user via email
Step 1. Check if the QR already exists by the Card ID you’d like to use
The following API checks whether a card is already posted on the system or not.
Make sure to use a card ID that is not used in this case to create & register a new QR code to a user.
[GET] /api/v2/cards/registered/?card_id={cardID}
[Response Body]: If the Card ID is not registered
{ "Response": { "code": "0" } } |
[Response Body]: If the Card ID is already used (registered)
{ "Card": { "id": 19, "crdTypUid": 6, "crdCsn": "444444444" }, "Response": { "code": "0" } } |
Step 2. Create a QR with Card ID that is Not In Use
The following API is used to add a QR to BioStar 2.
[POST] /api/cards
[Parameters]
Name | Type | Required | Explanation |
card_type.id | String | Y | desc: Card Type ID (0:CSN, 1:WIEGAND, 2:SECURE, 3:ACCESS, 4:CSN_MOBILE, 5:WIEGAND_MOBILE, 6:QR/Barcode, 7:BioStar 2 QR) |
card_type.name | String | N | Card Type Name |
card_type.type | String | Y | desc: Card Type(1:CSN, 2:SECURE, 3:ACCESS, 10:CSN_WIEGAND, 4:CSN_MOBILE, 5:WIEGAND_MOBILE, 6:QR/Barcode, 7:BioStar 2 QR) |
card_type.mode | String | N |
|
display_card_id | String | N | Card Display ID |
Card_id | String | Y | Card ID |
User_id.user_id | String | Y | User ID |
[Request Body Example]
[Response Body]
Please take a note of the card data from the response body. This value will be used when assigning the QR to a user and when sending an email to a user with the QR.
Step 3. Register QR to User
The following API edits user information. In this case, we are going to add a QR credential to a user.
[PUT] /api/users/{user_id}
[Query Parameter]
user_id Input the id of the user that you'd like to add the QR credential to.
[Request Body Example]
Use the "id" value obtained from the previous step.
[Response Body]
{ "Response": { "code": "0", "link": "https://support.supremainc.com/en/support/home", "message": "Success" } } |
Step 4. (ONLY for 'BioStar 2 QR') Send the QR to the user via email
The following API send BioStar 2 QR by email to a user.
POST /api/v2/send_email_qr
[Body Parameters]
Name | Type | Required | Explanation |
id | Number | Y | Id of user that will receive the email for the QR code that is registered |
language | String | Y | ko=Korean, en=English |
card_collection | Array | Y | QR code that is registered to the user and sent via email. Get QR data from Step 2. |
total | Number | Y | Total number of cards in card_collection |
[Example Request Body]
Use the card data obtained from the previous step.
After successfully running the API, you should receive a response like below and an email with the BioStar 2 QR.