Checking Transaction Status and Downloading Documents
A continuation of the steps in Creating and Sending a Transaction.
Retrieve Package JSON
HTTP Request
POST <host domain>/api/sign/v1/cs-packages/{packageId}
HTTP Headers
Accept: application/json; esl-api-version=11.21 Authorization: Bearer access_token
Retrieving Signing Status
HTTP Request
GET <host domain>/api/sign/v1/cs-packages/{packageId}/signingStatus?signer={signerId}&document={documentId}
HTTP Headers
Accept: application/json Authorization: Bearer access_token
Response Payload
{ "status": "COMPLETED" }
Download Zipped Documents
HTTP Request
GET <host domain>/api/sign/v1/cs-packages/{packageId}/documents/zip
HTTP Headers
Accept: application/zip Authorization: Bearer access_token
Download Evidence Summary
HTTP Request
GET <host domain>/api/sign/v1/cs-packages/{packageId}/evidence/summary
HTTP Headers
Accept: application/pdf Authorization: Bearer access_token
The first few lines define the connection info for Conga Sign. Make sure to replace the placeholder text with your API key
string apiKey = "YOUR_API_KEY"; string url = "https://sandbox.congasign.com/api";
Next, create the HttpClient that you will use for your GET requests and set the appropriate header authorization and accept values.
HttpClient myClient = new HttpClient(); myClient.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", access_token); myClient.DefaultRequestHeaders.Add("Accept", "application/json,application/zip,text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8");
Check the Status
Using the packageId previously mentioned, you can set up your GET request to verify the package status. Possible values are ARCHIVED, COMPLETED, DECLINED, DRAFT, EXPIRED, OPTED_OUT, and SENT. The code below performs a GET request to the URL created from the base URL defined previously, With the remainder of the URL from the appropriate REST call defined in the packageId above. The content of the response is then parsed into a JObject and the status property of the JObject is obtained and written to the Debug output.
var packageStatusResponse = myClient.GetAsync(new Uri(url + "/packages/YOUR_PACKAGE_ID")).Result; JObject packageStatusResponseJSON = JObject.Parse(packageStatusResponse.Content.ReadAsStringAsync().Result); var packageStatus = packageStatusResponseJSON["status"]; Debug.WriteLine("Package Status: " + packageStatus);
Next, check the signing status of the package. The possible values are ARCHIVED, CANCELLED, COMPLETE, DECLINED, EXPIRED, INACTIVE, OPTED_OUT, COMPLETED, and SIGNING_PENDING.
var signingStatusResponse = myClient.GetAsync(new Uri(url + "/packages/0487df67-6417-48f8-9575-b520c0f977ff/signingStatus")).Result; JObject signingStatusResponseJSON = JObject.Parse(signingStatusResponse.Content.ReadAsStringAsync().Result); var signingStatus = signingStatusResponseJSON["status"].ToString(); Debug.WriteLine("Signing Status: " + signingStatus);
Download the Files
Finally, check if the package is complete. If it is, the zip file of all documents will be downloaded as well as the audit trail.
if (signingStatus.Equals("COMPLETED")) { var downloadZipResponse = myClient.GetAsync(new Uri(url + "/packages/0487df67-6417-48f8-9575-b520c0f977ff/documents/zip")).Result; ByteArrayContent content = new ByteArrayContent(downloadZipResponse.Content.ReadAsByteArrayAsync().Result); File.WriteAllBytes("C:/Eclipse/myzip.zip", content.ReadAsByteArrayAsync().Result); Debug.WriteLine("Zip File Downloaded"); var evidenceSummaryResponse = myClient.GetAsync(new Uri(url + "/packages/0487df67-6417-48f8-9575-b520c0f977ff/evidence/summary")).Result; ByteArrayContent evidenceSummaryContent = new ByteArrayContent(evidenceSummaryResponse.Content.ReadAsByteArrayAsync().Result); File.WriteAllBytes("C:/Eclipse/myevidencesummary.pdf", evidenceSummaryContent.ReadAsByteArrayAsync().Result); Debug.WriteLine("Evidence Summary Downloaded"); } else { Debug.WriteLine("Signing not complete"); }