Sample code for 30+ languages & platforms
Lua

DocuSign List Folder Items

See more DocuSign Examples

Retrieves a list of the envelopes in the specified folder.

Chilkat Lua Downloads

Lua
local chilkat = require("chilkat")

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

local http = chilkat.Http.new()

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

-- Adds the "Authorization: Bearer eyJ0eXAi.....UE8Kl_V8KroQ" header.
local jsonToken = chilkat.JsonObject.new()
-- Load a previously obtained OAuth2 access token.
local success = jsonToken:load_file("qa_data/tokens/docusign.json")
if not success then
    print(jsonToken.last_error_text)
    return
end

http.auth_token = jsonToken:string_of("access_token")

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

local sbResponseBody = chilkat.StringBuilder.new()
success = http:quick_get_sb("https://demo.docusign.net/restapi/v2.1/accounts/{$accountId}/folders/{$folderId}", sbResponseBody)
if not success then
    print(http.last_error_text)
    return
end

local jResp = chilkat.JsonObject.new()
jResp:load_sb(sbResponseBody)
jResp.emit_compact = false

print("Response Body:")
print(jResp:emit())

local respStatusCode = http.last_status
print("Response Status Code = " .. respStatusCode)
if respStatusCode >= 400 then
    print("Response Header:")
    print(http.last_response_header)
    print("Failed.")
    return
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

local ownerName = ""
local envelopeId = ""
local envelopeUri = ""
local status = ""
local senderName = ""
local senderEmail = ""
local createdDateTime = ""
local sentDateTime = ""
local completedDateTime = ""
local subject = ""
local templateId = ""
local name = ""
local shared = ""
local password = ""
local description = ""
local lastModified = ""
local pageCount = 0
local uri = ""
local is21CFRPart11 = ""
local isSignatureProviderEnvelope = ""
local j = 0
local count_j = 0
local fieldId = ""
local show = ""
local required = ""
local value = ""
local configurationType = ""
local errorDetailsErrorCode = ""
local errorDetailsMessage = ""

local resultSetSize = jResp:string_of("resultSetSize")
local startPosition = jResp:string_of("startPosition")
local endPosition = jResp:string_of("endPosition")
local totalSetSize = jResp:string_of("totalSetSize")
local previousUri = jResp:string_of("previousUri")
local nextUri = jResp:string_of("nextUri")
local i = 0
local count_i = jResp:size_of_array("folderItems")
while i < count_i do
    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")
    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_of_array("folderItems[i].customFields")
    while j < count_j do
        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
    end

    i = i + 1
end