Sample code for 30+ languages & platforms
Swift

DocuSign List Folder Items

See more DocuSign Examples

Retrieves a list of the envelopes in the specified folder.

Chilkat Swift Downloads

Swift

func chilkatTest() {
    var success: Bool = false

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

    let http = CkoHttp()!

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

    // Adds the "Authorization: Bearer eyJ0eXAi.....UE8Kl_V8KroQ" header.
    let jsonToken = CkoJsonObject()!
    // Load a previously obtained OAuth2 access token.
    success = jsonToken.loadFile(path: "qa_data/tokens/docusign.json")
    if success == false {
        print("\(jsonToken.lastErrorText!)")
        return
    }

    http.authToken = jsonToken.string(of: "access_token")

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

    let sbResponseBody = CkoStringBuilder()!
    success = http.quickGetSb(url: "https://demo.docusign.net/restapi/v2.1/accounts/{$accountId}/folders/{$folderId}", sbContent: sbResponseBody)
    if success == false {
        print("\(http.lastErrorText!)")
        return
    }

    let jResp = CkoJsonObject()!
    jResp.loadSb(sb: sbResponseBody)
    jResp.emitCompact = false

    print("Response Body:")
    print("\(jResp.emit()!)")

    var respStatusCode: Int = http.lastStatus.intValue
    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: String?
    var envelopeId: String?
    var envelopeUri: String?
    var status: String?
    var senderName: String?
    var senderEmail: String?
    var createdDateTime: String?
    var sentDateTime: String?
    var completedDateTime: String?
    var subject: String?
    var templateId: String?
    var name: String?
    var shared: String?
    var password: String?
    var description: String?
    var lastModified: String?
    var pageCount: Int
    var uri: String?
    var is21CFRPart11: String?
    var isSignatureProviderEnvelope: String?
    var j: Int
    var count_j: Int
    var fieldId: String?
    var show: String?
    var required: String?
    var value: String?
    var configurationType: String?
    var errorDetailsErrorCode: String?
    var errorDetailsMessage: String?

    var resultSetSize: String? = jResp.string(of: "resultSetSize")
    var startPosition: String? = jResp.string(of: "startPosition")
    var endPosition: String? = jResp.string(of: "endPosition")
    var totalSetSize: String? = jResp.string(of: "totalSetSize")
    var previousUri: String? = jResp.string(of: "previousUri")
    var nextUri: String? = jResp.string(of: "nextUri")
    var i: Int = 0
    var count_i: Int = jResp.size(ofArray: "folderItems").intValue
    while i < count_i {
        jResp.i = i
        ownerName = jResp.string(of: "folderItems[i].ownerName")
        envelopeId = jResp.string(of: "folderItems[i].envelopeId")
        envelopeUri = jResp.string(of: "folderItems[i].envelopeUri")
        status = jResp.string(of: "folderItems[i].status")
        senderName = jResp.string(of: "folderItems[i].senderName")
        senderEmail = jResp.string(of: "folderItems[i].senderEmail")
        createdDateTime = jResp.string(of: "folderItems[i].createdDateTime")
        sentDateTime = jResp.string(of: "folderItems[i].sentDateTime")
        completedDateTime = jResp.string(of: "folderItems[i].completedDateTime")
        subject = jResp.string(of: "folderItems[i].subject")
        templateId = jResp.string(of: "folderItems[i].templateId")
        name = jResp.string(of: "folderItems[i].name")
        shared = jResp.string(of: "folderItems[i].shared")
        password = jResp.string(of: "folderItems[i].password")
        description = jResp.string(of: "folderItems[i].description")
        lastModified = jResp.string(of: "folderItems[i].lastModified")
        pageCount = jResp.int(of: "folderItems[i].pageCount").intValue
        uri = jResp.string(of: "folderItems[i].uri")
        is21CFRPart11 = jResp.string(of: "folderItems[i].is21CFRPart11")
        isSignatureProviderEnvelope = jResp.string(of: "folderItems[i].isSignatureProviderEnvelope")
        j = 0
        count_j = jResp.size(ofArray: "folderItems[i].customFields").intValue
        while j < count_j {
            jResp.j = j
            fieldId = jResp.string(of: "folderItems[i].customFields[j].fieldId")
            name = jResp.string(of: "folderItems[i].customFields[j].name")
            show = jResp.string(of: "folderItems[i].customFields[j].show")
            required = jResp.string(of: "folderItems[i].customFields[j].required")
            value = jResp.string(of: "folderItems[i].customFields[j].value")
            configurationType = jResp.string(of: "folderItems[i].customFields[j].configurationType")
            errorDetailsErrorCode = jResp.string(of: "folderItems[i].customFields[j].errorDetails.errorCode")
            errorDetailsMessage = jResp.string(of: "folderItems[i].customFields[j].errorDetails.message")
            j = j + 1
        }

        i = i + 1
    }


}