Sample code for 30+ languages & platforms
Tcl

Yousign: List Files

See more Yousign Examples

List Yousign files.

Chilkat Tcl Downloads

Tcl

load ./chilkat.dll

set success 0

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

set http [new_CkHttp]

# 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.
CkHttp_put_AuthToken $http "YOUR_API_KEY"
CkHttp_SetRequestHeader $http "Content-Type" "application/json"

set sbResponseBody [new_CkStringBuilder]

set success [CkHttp_QuickGetSb $http "https://staging-api.yousign.com/files" $sbResponseBody]
if {$success == 0} then {
    puts [CkHttp_lastErrorText $http]
    delete_CkHttp $http
    delete_CkStringBuilder $sbResponseBody
    exit
}

set json [new_CkJsonObject]

CkJsonObject_LoadSb $json $sbResponseBody
CkJsonObject_put_EmitCompact $json 0

puts "Response Body:"
puts [CkJsonObject_emit $json]

set respStatusCode [CkHttp_get_LastStatus $http]
puts "Response Status Code = $respStatusCode"
if {$respStatusCode >= 400} then {
    puts "Response Header:"
    puts [CkHttp_lastHeader $http]
    puts "Failed."
    delete_CkHttp $http
    delete_CkStringBuilder $sbResponseBody
    delete_CkJsonObject $json
    exit
}

# 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

set id [CkJsonObject_stringOf $json "id"]
set name [CkJsonObject_stringOf $json "name"]
set v_type [CkJsonObject_stringOf $json "type"]
set contentType [CkJsonObject_stringOf $json "contentType"]
set description [CkJsonObject_stringOf $json "description"]
set createdAt [CkJsonObject_stringOf $json "createdAt"]
set updatedAt [CkJsonObject_stringOf $json "updatedAt"]
set sha256 [CkJsonObject_stringOf $json "sha256"]
set workspace [CkJsonObject_stringOf $json "workspace"]
set creator [CkJsonObject_stringOf $json "creator"]
set v_protected [CkJsonObject_BoolOf $json "protected"]
set position [CkJsonObject_IntOf $json "position"]
set parent [CkJsonObject_stringOf $json "parent"]
set fieldsCompatible [CkJsonObject_BoolOf $json "fieldsCompatible"]
set company [CkJsonObject_stringOf $json "company"]
set i 0
set count_i [CkJsonObject_SizeOfArray $json "metadata"]
while {$i < $count_i} {
    CkJsonObject_put_I $json $i
    set i [expr $i + 1]
}
set i 0
set count_i [CkJsonObject_SizeOfArray $json "fileObjects"]
while {$i < $count_i} {
    CkJsonObject_put_I $json $i
    set i [expr $i + 1]
}

delete_CkHttp $http
delete_CkStringBuilder $sbResponseBody
delete_CkJsonObject $json