Introduction

If you’d like to use BioStar 2 New Local API as a RESTful API for your own customization or other purposes, you can simply reference this article. This article will cover the most basic usage of the BioStar 2 New Local API by C# console application. 

 

This is just a sample application made for those who might need to use the BioStar 2 New Local API. It is a Visual C# console application.

 

Features

This article will cover the function below:

  1. Register Visual Face via Send Email API
  2. Register Visual Face via Face Scanning by a device (FaceStation F2)

 

Through this article, you can learn how to call an API function to register Visual Face to the users in BioStar 2 server. There are 2 different ways to register Visual Face via New Local API.

 

Make sure you take a good look at the example code of the C# program built for API calls. You can simply copy & paste the source code to use the same function in your own integration. 

 

You can also see how to call the API functions via Postman, which is a program used for RESTful API calls.

*You must have the CLOUD SETTING all configured to use Send Email to Register Visual Face feature.

To configure CLOUD SETTING, please reference the article below:

https://kb.supremainc.com/knowledge/doku.php?id=en:how_to_use_mobile_app 

*You must have the EMAIL SETTING all configured to use Send Email to Register Visual Face feature.

To configure EMAIL SETTING, please follow the instructions below:

  1. Go to Biostar 2 > Settings > EMAIL SETTING

텍스트, 전자기기이(가) 표시된 사진

자동 생성된 설명

 

  1. Click on ‘SMTP setting’ and enter appropriate value for SMTP Option.

  1. Enable ‘Visual Face Mobile Enrollment’ and fill in the additional options (Email Title, Company Name, Company Logo, Contact) if you’d like to have them configured for your emails.

텍스트이(가) 표시된 사진

자동 생성된 설명

  1. And lastly, the user must have his or her email registered.

 

 

 

Part 1. API Call & Parameters 

 

[POST]: /api/v2/send_email

[Parameters] 

Name

Type

*M/O

Explanation

Value

Id

String

O

Id of the selected User

 

Language

String

O

Selected language in which the email will be written

“en” for English

   * M – Mandatory, O – Optional

 

Part 2. Request Body & Response Model

[Example Value/Parameters Model]

{

     "id": "2",

     "language": "en"

}

 

[Response Model]

{

  "code": "0",

  "httpResponseStatus": 200

}

[Response: Fail]

{

    "code": "1000"

}

[Response: Successful]

{

    "code": "0"

}

 

Part 3. Console Example

 

[Sending Email(for Visual Face Registration) Method Source Code] 

static async void EmailVisualFaceReg()

        {

            Console.WriteLine("*****EmailVisualFaceReg Task Started*****");

            CookieContainer cookieContainer = new CookieContainer();

 

            HttpClientHandler handler = new HttpClientHandler();

            handler.CookieContainer = cookieContainer;

 

            HttpClient httpClient = new HttpClient(handler);

 

            HttpClient client = new HttpClient(handler);

               httpClient.DefaultRequestHeaders.Add("bs-session-id", sessionID);

            cookieContainer.Add(new Uri("https://127.0.0.1"), new Cookie("bs-session-id", sessionID));

            ListUsers();

            Console.WriteLine("Select User ID for Visual Face Registration via Email...");

            string userID = Console.ReadLine();

            string resourceAddress = "https://127.0.0.1/api/v2/send_email/";

 

            JavaScriptSerializer serializer = new JavaScriptSerializer();

 

            string payload = "{ \"id\": \"" + userID + "\", \"language\": \"en\"}";

            Console.WriteLine(payload);

            StringContent sc = new StringContent(payload, Encoding.UTF8, "application/json");

            //HttpResponseMessage httpResponse = await httpClient.PostAsync(resourceAddress, sc);

            HttpResponseMessage httpResponse = httpClient.PostAsync(resourceAddress, sc).Result;

 

            if (httpResponse.IsSuccessStatusCode == true)

            {

                Console.WriteLine("Email Sent. Check your Email.");

                string httpResponseBody = await httpResponse.Content.ReadAsStringAsync();

                   Console.WriteLine(httpResponseBody);

            }

            else

            {

                Console.WriteLine("Email Send Failed.");

                   Console.WriteLine(httpResponse.ToString());

            }

        }

 

[Sending Email(for Visual Face Registration) Successfully] 

텍스트이(가) 표시된 사진

자동 생성된 설명

 

[Email Received]

 

 

 

Part 4. Register Visual Face via Postman

 

[Request] 

*You must enter the User_ID with the email already registered.

 

[Response Body: Success]