Certiverse Test Driver Integration

Launch Certiverse exams from 3rd party applications.

Overview

Giving third parties the ability to utilize Certiverse as their test driver for test delivery

Version Information

Version: 1.3

URI Scheme

Base Path: /api

Scheme: HTTPS

Paths

Summary

Authenticate as a Certiverse partner to gain an authentication token for calls needing to be executed.

GET /authenticate

Headers

Key

Description

Value

x-functions-key

API endpoint secret used for security

string: <value provided by Certiverse>

Authorization

Basic Auth

ClientId: String value provided by Certiverse

ClientSecret: String value provided by Certiverse

Query Parameters

Parameter

Description

Type

Code

Optional value to pass in that will be returned telling the caller API call has not been intercepted

string (optional)

Responses

http Status Code

Description

Schema

200

Return authentication token

PartnerDataTokensModel

400

Error if request is missing or invalid properties

ErrorModel

401

Error if credentials are incorrect

ErrorModel

500

Error if server errors

ErrorModel

 

Models

PartnerDataTokensModel (ContentType: application/json)

Property

Description

Type

authToken

Token for authorization on any other calls

string

code

Value provided in request returned 

string

ErrorModel (ContentType: application/json)

Property

Description

Type

errorCode

Internal error code

string (optional)

errorMessages

List of error messages

string[]

 

Summary

Validate information and prepare an exam to be proctored by a third party returning an encrypted launch url

POST /provision

Headers

Key

Description

Value

authorization

Authorization Bearer token

Bearer <token from authenticate call>

Parameters

Type

Description

Schema

Body

 

ProvisioningCommand

Responses

Http StatusCode

Description

Schema

200

 

ProvisioningModel

400

Error if request is missing or invalid properties

ErrorModel

401

Error if credentials are incorrect

ErrorModel

500

Error if server errors

ErrorModel

Commands

ProvisioningCommand

Contains information required to provision an exam for a Candidate. 

Name 

Schema 

candidate required 

CandidateCommand

reservation required 

ReservationCommand

exam required

 ExamCommand

CandidateCommand

Candidate’s basic information 

Name 

Description 

Schema 

candidateId required 

Candidate’s Unique Id.

string 

country optional 

2 digit country code per https://en.wikipedia.org/wiki/ISO_3166-1_alpha-2 standards.

string 

email required 

Candidate’s Email. 

string 

firstName required

Candidate’s Given Name.

string 

lastName required 

Candidate’s Family Name. 

string 

ReservationCommand

Candidate’s reservation details like booking related information. 

Name 

Description 

Schema 

bookingCode required 

Unique identifier to identify the schedule or booking of the Candidate. 

 string 

eligibilityId optional 

Unique identifier to identify the registration or eligibility of the Candidate. 

 string 

ExamCommand

Candidate’s exam related information. 

Name 

Description 

Schema 

code required 

 Provided client specific exam code. 

 string 

language optional 

 Exam language in country-region format, i.e., en-US or fr-FR. 

 string 

returnUrl optional

URL Candidate will be returned to after the last screen in the Certiverse exam delivery.

string

additionalTime optional

Additional time in MINUTES for the candidate to take the exam.

int

Models

ProvisioningModel (ContentType: application/json)

Contains launch url. 

 

Name 

Schema 

encrypter_launch_url 

 String (encrypted)

Summary

Validate information and stop an exam currently proctored by a third party

POST /exam/stop

Headers

Key

Description

Value

authorization

Authorization Bearer token

Bearer <token from authenticate call>

Parameters

Type

Description

Schema

Body

Command described with the following schema

PartnerExamStopCommand

PartnerExamStopCommand (ContentType: application/json)

*Note: Properties here are taken from the ProvisiongCommand used during the Provision call. 

Property

Description

Type

bookingCode

Required: Id as passed in during Provision that defines the registration on the partner side

string

candidateId

Required: Id of the candidate on the partner side

string

email

Optional:  If email of test taker is available

string

C# Code Samples:

Authenticate

private const string FunctionKey = "";
private const string ClientId = "";
private const string ClientSecret = "";
private const string Endpoint = "https://partner.certiverse.com/api/authenticate";
    
public static string GetJwt()
{
    using (HttpClient httpClient = new HttpClient())
    {
        string callingCode = System.Guid.NewGuid().ToString();
        using (HttpRequestMessage request = new HttpRequestMessage(new HttpMethod("GET"), $"{Endpoint}?code={callingCode}"))
        {
            // Set the Function Key header
            request.Headers.TryAddWithoutValidation("x-functions-key", FunctionKey);

            // Set the Authorization Header
            // Get Base64 Encoded String
            byte[] plainTextBytes = System.Text.Encoding.UTF8.GetBytes($"{ClientId}:{ClientSecret}");
            string encodedConsumerCredentials = System.Convert.ToBase64String(plainTextBytes);
            request.Headers.TryAddWithoutValidation("Authorization", $"Basic {encodedConsumerCredentials}");

            try
            {
                // Make the call
                HttpResponseMessage response = httpClient.Send(request);

                // Handle the response
                if (response.IsSuccessStatusCode)
                {
                    using (HttpContent responseContent = response.Content)
                    {
                        string successResponse = responseContent.ReadAsStringAsync().Result;
                        ResponseModel responseModel = JsonSerializer.Deserialize<ResponseModel>(successResponse);

                        if (responseModel == null)
                        {
                            throw new System.Exception("Unable to deserialize response");
                        }

                        // Optional: If passed in a code, validate code is returned
                        if (!string.Equals(responseModel.Code, callingCode))
                        {
                            // Handle code being intercepted
                            throw new System.Exception("Calling Code Mismatch");
                        }

                        return responseModel.BearerToken;
                    }
                }
                else
                {
                    // Handle non-success response
                    throw new System.Exception($"Invalid response: {response.StatusCode}");
                }
            }
            catch (System.Exception ex)
            {
                // Handle Exception
                throw;
            }
        }
    }
}

 

Provision Call

 private const string BearerToken = ""; //retrieved from previous call
private const string Endpoint = "https://partner.certiverse.com/api/provision";

private string GetLaunchUrl()
{

    using (HttpClient httpClient = new HttpClient())
    {
        using (HttpRequestMessage request = new HttpRequestMessage(new HttpMethod("POST"), Endpoint))
        {
            // Set the Authorization Header
            request.Headers.TryAddWithoutValidation("Authorization", $"Bearer {BearerToken}");

            // Set the body of the call
            // Define the request object
            ProvisionRequest provisionRequest = new ProvisionRequest
            {
                Candidate = new ProvisionCandidate
                {
                    CandidateId = "",
                    Country = "",
                    Email = "",
                    FirstName = "",
                    LastName = ""
                },

                Reservation = new ProvisionReservation
                {
                    BookingCode = "",
                    EligibilityId = "",
                },

                Exam = new ProvisionExam
                {
                    ExamCode = "",
                    Language = "",
                    ReturnUrl = null, // null or valid URL. Empty is not accepted
                    AdditionalTime = null
                }
            };
            string provisionRequestBody = JsonSerializer.Serialize(provisionRequest);
            request.Content = new StringContent(provisionRequestBody, Encoding.UTF8, "application/json");

            try
            {
                // Make the call
                HttpResponseMessage response = httpClient.Send(request);

                // Handle the response
                if (response.IsSuccessStatusCode)
                {
                    using (HttpContent responseContent = response.Content)
                    {
                        string successResponse = responseContent.ReadAsStringAsync().Result;
                        ResponseModel responseModel = JsonSerializer.Deserialize<ResponseModel>(successResponse);

                        if (responseModel == null)
                            throw new System.Exception("Unable to deserialize response");

                        return responseModel.EncryptedLaunchUrl;
                    }
                }
                else
                {
                    // Handle non-success response
                    throw new System.Exception($"Invalid response: {response.StatusCode}");
                }
            }
            catch (Exception ex)
            {
                // Handle Exception
                throw;
            }
        }
    }
}

 

Stop Exam

 private const string BearerToken = "";
private const string Endpoint = "https://partner.certiverse.com/api/exam/stop";

private void StopExam()
{
    using (HttpClient httpClient = new HttpClient())
    {
        using (HttpRequestMessage request = new HttpRequestMessage(new HttpMethod("POST"), Endpoint))
        {
            // Set the Authorization Header
            request.Headers.TryAddWithoutValidation("Authorization", $"Bearer {BearerToken}");

            // Set the body of the call
            // Define the request object
            ExamStopRequest provisionRequest = new ExamStopRequest
            {
                BookingCode = "",
                CandidateId = "",
                Email = ""
            };
            string provisionRequestBody = JsonSerializer.Serialize(provisionRequest);
            request.Content = new StringContent(provisionRequestBody, Encoding.UTF8, "application/json");

            try
            {
                // Make the call
                HttpResponseMessage response = httpClient.Send(request);

                // Handle the response
                if (!response.IsSuccessStatusCode)
                    throw new System.Exception($"Unable to Stop Exam. Response: {response.StatusCode}");
            }
            catch (Exception ex)
            {
                // Handle Exception
                throw;
            }
        }
    }
}

Contact Us

If you have any questions or need additional assistance, please contact us by either emailing support@certiverse.com or by submitting a ticket from this article.