GET /isenrolled?bcid={BCID}&trait={Trait}
Find out whether a user is already enrolled for a specific trait.
Sometimes it is useful to know whether there is a template available for a specific user and trait before a client tries to perform a verification of this user using this trait. If no template is available, i.e. the user is not yet enrolled, the client could use another authentication mechanism and send the user to the enrollment procedure.
The IsEnrolled
Web API does not return any response body, it simply returns a HTTP status code indicating whether the user is enrolled (200 OK)
or not (404 Not Found).
private static async Task<bool> IsEnrolledAsync(string bcid, Trait trait)
{
using (var client = new HttpClient())
{
client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Basic", Convert.ToBase64String(Encoding.ASCII.GetBytes($"{APP_IDENTIFIER}:{APP_SECRET}")));
using (var response = await client.GetAsync(ENDPOINT + $"isenrolled?bcid={bcid}&trait={trait}"))
{
Console.Write("IsEnrolled response... ");
if (response.StatusCode == HttpStatusCode.OK)
{
Console.WriteLine(true);
return true;
}
Console.WriteLine(response.StatusCode.ToString());
return false;
}
}
}
jQuery.ajax({
url: "https://bws.bioid.com/extension/isenrolled",
type: "GET",
data: {
"bcid": `${STORAGE}.${PARTITION}.${CLASS_ID}`,
"trait": "face"
},
headers: {
"Authorization": "Basic " + btoa(APP_IDENTIFIER + ":" + APP_SECRET),
},
}).done(function (data, textStatus, jqXHR) {
console.log("template for face is available");
}).fail(function(jqXHR, textStatus, errorThrown) {
if(jqXHR.status === 404) {
console.log("template for face is not available");
} else {
console.log("request failed");
}
});
// using OkHttpClient from the OkHttp library
HttpUrl url = HttpUrl.parse("https://bws.bioid.com/extension/isenrolled").newBuilder()
.addQueryParameter("bcid", STORAGE + "." + PARTITION + "." + CLASS_ID)
.addQueryParameter("trait", "face")
.build();
Request request = new Request.Builder()
.url(url)
.addHeader("Authorization", Credentials.basic(APP_IDENTIFIER, APP_SECRET))
.build();
OkHttpClient client = new OkHttpClient();
Response response = client.newCall(request).execute();
switch (response.code()) {
case 200:
System.out.println("template for face is available");
break;
case 404:
System.out.println("template for face is not available");
break;
default:
System.out.println("request failed");
break;
}