Lua
Lua
Yousign: List Files
See more Yousign Examples
List Yousign files.Chilkat Lua Downloads
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 CURL command:
-- curl --location --request GET 'https://staging-api.yousign.com/files' \
-- --header 'Authorization: Bearer YOUR_API_KEY' \
-- --header 'Content-Type: application/json'
-- Use the following online tool to generate HTTP code from a CURL command
-- Convert a cURL Command to HTTP Source Code
-- Adds the "Authorization: Bearer YOUR_API_KEY" header.
http.auth_token = "YOUR_API_KEY"
http:set_request_header("Content-Type", "application/json")
local sbResponseBody = chilkat.StringBuilder.new()
local success = http:quick_get_sb("https://staging-api.yousign.com/files", sbResponseBody)
if not success then
print(http.last_error_text)
return
end
local json = chilkat.JsonObject.new()
json:load_sb(sbResponseBody)
json.emit_compact = false
print("Response Body:")
print(json:emit())
local respStatusCode = http.last_status
print("Response Status Code = " .. respStatusCode)
if respStatusCode >= 400 then
print("Response Header:")
print(http.last_header)
print("Failed.")
return
end
-- Sample JSON response:
-- (Sample code for parsing the JSON response is shown below)
-- {
-- "id": "\/files\/XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX",
-- "name": "abc.pdf",
-- "type": "signable",
-- "contentType": "application\/pdf",
-- "description": null,
-- "createdAt": "2020-05-27T09:14:12+02:00",
-- "updatedAt": "2020-05-27T09:14:12+02:00",
-- "sha256": "ea2a92b0eff5bebfa3ccd869fd61e27bb7fe973d0dff63f106d8b0d614469fa0",
-- "metadata": [
-- ],
-- "workspace": "\/workspaces\/XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX",
-- "creator": null,
-- "fileObjects": [
-- ],
-- "protected": false,
-- "position": 0,
-- "parent": null,
-- "fieldsCompatible": true,
-- "company": "\/companies\/XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX"
-- }
-- Use the following online tool to generate parsing code from sample JSON:
-- Generate Parsing Code from JSON
local id = json:string_of("id")
local name = json:string_of("name")
local v_type = json:string_of("type")
local contentType = json:string_of("contentType")
local description = json:string_of("description")
local createdAt = json:string_of("createdAt")
local updatedAt = json:string_of("updatedAt")
local sha256 = json:string_of("sha256")
local workspace = json:string_of("workspace")
local creator = json:string_of("creator")
local v_protected = json:bool_of("protected")
local position = json:int_of("position")
local parent = json:string_of("parent")
local fieldsCompatible = json:bool_of("fieldsCompatible")
local company = json:string_of("company")
local i = 0
local count_i = json:size_of_array("metadata")
while i < count_i do
json.i = i
i = i + 1
end
i = 0
count_i = json:size_of_array("fileObjects")
while i < count_i do
json.i = i
i = i + 1
end