Delphi DLL
Delphi DLL
DocuSign List Folder Items
See more DocuSign Examples
Retrieves a list of the envelopes in the specified folder.Chilkat Delphi DLL Downloads
uses
Winapi.Windows, Winapi.Messages, System.SysUtils, System.Variants, System.Classes, Vcl.Graphics,
Vcl.Controls, Vcl.Forms, Vcl.Dialogs, Vcl.StdCtrls, Http, StringBuilder, JsonObject;
...
procedure TForm1.Button1Click(Sender: TObject);
var
success: Boolean;
http: HCkHttp;
jsonToken: HCkJsonObject;
sbResponseBody: HCkStringBuilder;
jResp: HCkJsonObject;
respStatusCode: Integer;
ownerName: PWideChar;
envelopeId: PWideChar;
envelopeUri: PWideChar;
status: PWideChar;
senderName: PWideChar;
senderEmail: PWideChar;
createdDateTime: PWideChar;
sentDateTime: PWideChar;
completedDateTime: PWideChar;
subject: PWideChar;
templateId: PWideChar;
name: PWideChar;
shared: PWideChar;
password: PWideChar;
description: PWideChar;
lastModified: PWideChar;
pageCount: Integer;
uri: PWideChar;
is21CFRPart11: PWideChar;
isSignatureProviderEnvelope: PWideChar;
j: Integer;
count_j: Integer;
fieldId: PWideChar;
show: PWideChar;
required: PWideChar;
value: PWideChar;
configurationType: PWideChar;
errorDetailsErrorCode: PWideChar;
errorDetailsMessage: PWideChar;
resultSetSize: PWideChar;
startPosition: PWideChar;
endPosition: PWideChar;
totalSetSize: PWideChar;
previousUri: PWideChar;
nextUri: PWideChar;
i: Integer;
count_i: Integer;
begin
success := False;
// This example assumes the Chilkat API to have been previously unlocked.
// See Global Unlock Sample for sample code.
http := CkHttp_Create();
// Implements the following HTTP request:
// GET /restapi/v2.1/accounts/{accountId}/folders/{folderId}
// Adds the "Authorization: Bearer eyJ0eXAi.....UE8Kl_V8KroQ" header.
jsonToken := CkJsonObject_Create();
// Load a previously obtained OAuth2 access token.
success := CkJsonObject_LoadFile(jsonToken,'qa_data/tokens/docusign.json');
if (success = False) then
begin
Memo1.Lines.Add(CkJsonObject__lastErrorText(jsonToken));
Exit;
end;
CkHttp_putAuthToken(http,CkJsonObject__stringOf(jsonToken,'access_token'));
// Use your account ID and a valid folderId here:
CkHttp_SetUrlVar(http,'accountId','7f3f65ed-5e87-418d-94c1-92499ddc8252');
CkHttp_SetUrlVar(http,'folderId','94644782-31b7-4f82-a2c1-26d8a9306f8c');
sbResponseBody := CkStringBuilder_Create();
success := CkHttp_QuickGetSb(http,'https://demo.docusign.net/restapi/v2.1/accounts/{$accountId}/folders/{$folderId}',sbResponseBody);
if (success = False) then
begin
Memo1.Lines.Add(CkHttp__lastErrorText(http));
Exit;
end;
jResp := CkJsonObject_Create();
CkJsonObject_LoadSb(jResp,sbResponseBody);
CkJsonObject_putEmitCompact(jResp,False);
Memo1.Lines.Add('Response Body:');
Memo1.Lines.Add(CkJsonObject__emit(jResp));
respStatusCode := CkHttp_getLastStatus(http);
Memo1.Lines.Add('Response Status Code = ' + IntToStr(respStatusCode));
if (respStatusCode >= 400) then
begin
Memo1.Lines.Add('Response Header:');
Memo1.Lines.Add(CkHttp__lastResponseHeader(http));
Memo1.Lines.Add('Failed.');
Exit;
end;
// Sample JSON response:
// (Sample code for parsing the JSON response is shown below)
// {
// "resultSetSize": "sample string 1",
// "startPosition": "sample string 2",
// "endPosition": "sample string 3",
// "totalSetSize": "sample string 4",
// "previousUri": "sample string 5",
// "nextUri": "sample string 6",
// "folderItems": [
// {
// "ownerName": "sample string 1",
// "envelopeId": "sample string 2",
// "envelopeUri": "sample string 3",
// "status": "sample string 4",
// "senderName": "sample string 5",
// "senderEmail": "sample string 6",
// "createdDateTime": "sample string 7",
// "sentDateTime": "sample string 8",
// "completedDateTime": "sample string 9",
// "subject": "sample string 10",
// "templateId": "sample string 11",
// "name": "sample string 12",
// "shared": "sample string 13",
// "password": "sample string 14",
// "description": "sample string 15",
// "lastModified": "sample string 16",
// "pageCount": 17,
// "uri": "sample string 18",
// "is21CFRPart11": "sample string 19",
// "isSignatureProviderEnvelope": "sample string 20",
// "customFields": [
// {
// "fieldId": "sample string 1",
// "name": "sample string 2",
// "show": "sample string 3",
// "required": "sample string 4",
// "value": "sample string 5",
// "configurationType": "sample string 6",
// "errorDetails": {
// "errorCode": "sample string 1",
// "message": "sample string 2"
// }
// }
// ]
// }
// ]
// }
// Sample code for parsing the JSON response...
// Use the following online tool to generate parsing code from sample JSON:
// Generate Parsing Code from JSON
resultSetSize := CkJsonObject__stringOf(jResp,'resultSetSize');
startPosition := CkJsonObject__stringOf(jResp,'startPosition');
endPosition := CkJsonObject__stringOf(jResp,'endPosition');
totalSetSize := CkJsonObject__stringOf(jResp,'totalSetSize');
previousUri := CkJsonObject__stringOf(jResp,'previousUri');
nextUri := CkJsonObject__stringOf(jResp,'nextUri');
i := 0;
count_i := CkJsonObject_SizeOfArray(jResp,'folderItems');
while i < count_i do
begin
CkJsonObject_putI(jResp,i);
ownerName := CkJsonObject__stringOf(jResp,'folderItems[i].ownerName');
envelopeId := CkJsonObject__stringOf(jResp,'folderItems[i].envelopeId');
envelopeUri := CkJsonObject__stringOf(jResp,'folderItems[i].envelopeUri');
status := CkJsonObject__stringOf(jResp,'folderItems[i].status');
senderName := CkJsonObject__stringOf(jResp,'folderItems[i].senderName');
senderEmail := CkJsonObject__stringOf(jResp,'folderItems[i].senderEmail');
createdDateTime := CkJsonObject__stringOf(jResp,'folderItems[i].createdDateTime');
sentDateTime := CkJsonObject__stringOf(jResp,'folderItems[i].sentDateTime');
completedDateTime := CkJsonObject__stringOf(jResp,'folderItems[i].completedDateTime');
subject := CkJsonObject__stringOf(jResp,'folderItems[i].subject');
templateId := CkJsonObject__stringOf(jResp,'folderItems[i].templateId');
name := CkJsonObject__stringOf(jResp,'folderItems[i].name');
shared := CkJsonObject__stringOf(jResp,'folderItems[i].shared');
password := CkJsonObject__stringOf(jResp,'folderItems[i].password');
description := CkJsonObject__stringOf(jResp,'folderItems[i].description');
lastModified := CkJsonObject__stringOf(jResp,'folderItems[i].lastModified');
pageCount := CkJsonObject_IntOf(jResp,'folderItems[i].pageCount');
uri := CkJsonObject__stringOf(jResp,'folderItems[i].uri');
is21CFRPart11 := CkJsonObject__stringOf(jResp,'folderItems[i].is21CFRPart11');
isSignatureProviderEnvelope := CkJsonObject__stringOf(jResp,'folderItems[i].isSignatureProviderEnvelope');
j := 0;
count_j := CkJsonObject_SizeOfArray(jResp,'folderItems[i].customFields');
while j < count_j do
begin
CkJsonObject_putJ(jResp,j);
fieldId := CkJsonObject__stringOf(jResp,'folderItems[i].customFields[j].fieldId');
name := CkJsonObject__stringOf(jResp,'folderItems[i].customFields[j].name');
show := CkJsonObject__stringOf(jResp,'folderItems[i].customFields[j].show');
required := CkJsonObject__stringOf(jResp,'folderItems[i].customFields[j].required');
value := CkJsonObject__stringOf(jResp,'folderItems[i].customFields[j].value');
configurationType := CkJsonObject__stringOf(jResp,'folderItems[i].customFields[j].configurationType');
errorDetailsErrorCode := CkJsonObject__stringOf(jResp,'folderItems[i].customFields[j].errorDetails.errorCode');
errorDetailsMessage := CkJsonObject__stringOf(jResp,'folderItems[i].customFields[j].errorDetails.message');
j := j + 1;
end;
i := i + 1;
end;
CkHttp_Dispose(http);
CkJsonObject_Dispose(jsonToken);
CkStringBuilder_Dispose(sbResponseBody);
CkJsonObject_Dispose(jResp);
end;