Sample code for 30+ languages & platforms
Dart

DocuSign List Folder Items

See more DocuSign Examples

Retrieves a list of the envelopes in the specified folder.

Chilkat Dart Downloads

Dart
import 'package:chilkat/chilkat.dart';

void main() {
  // This example assumes the Chilkat API to have been previously unlocked.
  // See Global Unlock Sample for sample code.

  final http = CkHttp();

  // Implements the following HTTP request:
  // GET /restapi/v2.1/accounts/{accountId}/folders/{folderId}

  // Adds the "Authorization: Bearer eyJ0eXAi.....UE8Kl_V8KroQ" header.
  final jsonToken = CkJsonObject();
  // Load a previously obtained OAuth2 access token.
  try {
    jsonToken.loadFile('qa_data/tokens/docusign.json');
  } on ChilkatException catch (e) {
    print(e.lastErrorText);
    return;
  }

  http.authToken = jsonToken.stringOf('access_token');

  // Use your account ID and a valid folderId here:
  http.setUrlVar('accountId', '7f3f65ed-5e87-418d-94c1-92499ddc8252');
  http.setUrlVar('folderId', '94644782-31b7-4f82-a2c1-26d8a9306f8c');

  final sbResponseBody = CkStringBuilder();
  try {
    http.quickGetSb('https://demo.docusign.net/restapi/v2.1/accounts/{\$accountId}/folders/{\$folderId}', sbResponseBody);
  } on ChilkatException catch (e) {
    print(e.lastErrorText);
    return;
  }

  final jResp = CkJsonObject();
  jResp.loadSb(sbResponseBody);
  jResp.emitCompact = false;

  print('Response Body:');
  print(jResp.emit());

  final respStatusCode = http.lastStatus;
  print('Response Status Code = $respStatusCode');
  if (respStatusCode >= 400) {
    print('Response Header:');
    print(http.lastResponseHeader);
    print('Failed.');
    return;
  }

  // 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

  var ownerName = '';
  var envelopeId = '';
  var envelopeUri = '';
  var status = '';
  var senderName = '';
  var senderEmail = '';
  var createdDateTime = '';
  var sentDateTime = '';
  var completedDateTime = '';
  var subject = '';
  var templateId = '';
  var name = '';
  var shared = '';
  var password = '';
  var description = '';
  var lastModified = '';
  var pageCount = 0;
  var uri = '';
  var is21CFRPart11 = '';
  var isSignatureProviderEnvelope = '';
  var j = 0;
  var countJ = 0;
  var fieldId = '';
  var showVar = '';
  var requiredVar = '';
  var value = '';
  var configurationType = '';
  var errorDetailsErrorCode = '';
  var errorDetailsMessage = '';

  final resultSetSize = jResp.stringOf('resultSetSize');
  final startPosition = jResp.stringOf('startPosition');
  final endPosition = jResp.stringOf('endPosition');
  final totalSetSize = jResp.stringOf('totalSetSize');
  final previousUri = jResp.stringOf('previousUri');
  final nextUri = jResp.stringOf('nextUri');
  var i = 0;
  final countI = jResp.sizeOfArray('folderItems');
  while (i < countI) {
    jResp.i = i;
    ownerName = jResp.stringOf('folderItems[i].ownerName');
    envelopeId = jResp.stringOf('folderItems[i].envelopeId');
    envelopeUri = jResp.stringOf('folderItems[i].envelopeUri');
    status = jResp.stringOf('folderItems[i].status');
    senderName = jResp.stringOf('folderItems[i].senderName');
    senderEmail = jResp.stringOf('folderItems[i].senderEmail');
    createdDateTime = jResp.stringOf('folderItems[i].createdDateTime');
    sentDateTime = jResp.stringOf('folderItems[i].sentDateTime');
    completedDateTime = jResp.stringOf('folderItems[i].completedDateTime');
    subject = jResp.stringOf('folderItems[i].subject');
    templateId = jResp.stringOf('folderItems[i].templateId');
    name = jResp.stringOf('folderItems[i].name');
    shared = jResp.stringOf('folderItems[i].shared');
    password = jResp.stringOf('folderItems[i].password');
    description = jResp.stringOf('folderItems[i].description');
    lastModified = jResp.stringOf('folderItems[i].lastModified');
    pageCount = jResp.intOf('folderItems[i].pageCount');
    uri = jResp.stringOf('folderItems[i].uri');
    is21CFRPart11 = jResp.stringOf('folderItems[i].is21CFRPart11');
    isSignatureProviderEnvelope = jResp.stringOf('folderItems[i].isSignatureProviderEnvelope');
    j = 0;
    countJ = jResp.sizeOfArray('folderItems[i].customFields');
    while (j < countJ) {
      jResp.j = j;
      fieldId = jResp.stringOf('folderItems[i].customFields[j].fieldId');
      name = jResp.stringOf('folderItems[i].customFields[j].name');
      showVar = jResp.stringOf('folderItems[i].customFields[j].show');
      requiredVar = jResp.stringOf('folderItems[i].customFields[j].required');
      value = jResp.stringOf('folderItems[i].customFields[j].value');
      configurationType = jResp.stringOf('folderItems[i].customFields[j].configurationType');
      errorDetailsErrorCode = jResp.stringOf('folderItems[i].customFields[j].errorDetails.errorCode');
      errorDetailsMessage = jResp.stringOf('folderItems[i].customFields[j].errorDetails.message');
      j++;
    }

    i++;
  }
}