Completing an Assembly Session

The complete assembly session API method enables you to mark an assembly session as complete and produce output data from the assembly session, typically assembled documents.

Prerequisites

Before making an 'begin assembly session' request, you must have an access token to sign the request. You can retrieve an access token using one of the following flows:

Additionally, you must have the following items in the tenancy for which you are creating an assembly session:

Overview

The 'complete assembly session' API method is a command method. The API client invoking this method must have either a command or a root scope.

Once an assembly session for a work item is complete, you can create a new assembly session.

Authentication

See Authentication for more information about authenticating requests to the Advance API.

API Documentation

You can view the latest reference documentation for the Advance API at https://yourorganization.com/HdaApi/rest/documentation/index.html, where yourorganization.com is the domain under which your Advance deployment is located.

Request

Request URL

PUT https://{tenancymoniker}.{domain}/HdaApi/rest/v1.1/WorkItems/{id}/Versions/Active/CompleteSession

Headers

Key Required Description Example value
Authorization Yes The Authorization header for the request. Uses the access token retrieved (see Prerequisites section above for more information). Bearer [access token]

Parameters

Name Type Location Required Description
tenancymoniker String

URL

Yes The tenancy moniker for the tenancy in which you want to create the new work item.
domain String

URL

Yes Your domain. For example, yourorganization.com.
id Guid

URL

Yes The Guid for an existing work item.
runAssembly Boolean

Body

No Defaults to true. Either assemble documents for the work item (true) or complete the session without assembling documents (false).

Examples

Example Request URL

https://tenancy1.yourorganization.com/HdaApi/rest/v1.1/WorkItems/2d9f3d10-6fdb-494f-9929-955515c6f114/Versions/Active/CompleteSession

Example Request JSON
{
    runAssembly : true
}
Example Response

Status: 200 OK

Code Example

C#

Note: this code example assumes that you are using .Net Framework 4.6 and an ASP.NET Web Application project, and have completed the beginning an assembly session and displaying an interview topics.

HomeController.cs

Add the following methods to the existing HomeController class:

[HttpPost]
public async Task CompleteAssemblySession(string workItemId, string token)
{
    // Note: if you are not displaying an interview, you can call CompleteAssemblySession directly after the BeginAssemblySession call in the Index controller method
    await AssemblySessionHandler.CompleteAssemblySession(Guid.Parse(workItemId), token);            
}
public ActionResult LandingPage()
{
    // Landing page for the user when they finish the interview; this endpoint is used in InterviewOptions, on the interview page.
    return View();
}

AssemblySessionHandler.cs

Add the following methods to the existing AssemblySessionHandler class. You will need to update the assemblySessionUrl variable to use your own Advance API endpoint.

public static async Task<HttpStatusCode> CompleteAssemblySession(Guid workItemId, string token)
{
    // Create the 'create assembly session' request                 
    var request = CreateAssemblySessionCompleteHttpRequestMessage(workItemId);
    // Send create user request to Advance
    using (var client = new HttpClient())
    {
        client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token);
        var response = await client.SendAsync(request);
        return response.StatusCode;
    }
}
private static HttpRequestMessage CreateAssemblySessionCompleteHttpRequestMessage(Guid workItemId)
{            
    // Create the request for the 'create assembly session' API endpoint
    var assemblySessionUrl = $"https://tenancy1.yourorganization.com/HdaApi/rest/v1.1/WorkItems/{workItemId}/Versions/Active/CompleteSession";
    var body = new
    {
        runAssembly = true
    };
    return new HttpRequestMessage
    {
        RequestUri = new Uri(assemblySessionUrl),
        Method = HttpMethod.Put,
        Content = new StringContent(JsonConvert.SerializeObject(body), Encoding.UTF8, "application/json")
    };
}

LandingPage.cshtml

<h2>Assembly Complete!</h2>

Next steps