Xbase++
Xbase++
Yousign: Download Information about Previously Uploaded File
See more Yousign Examples
Demonstrates how to download the information (in JSON format) about a file previously uploaded.Chilkat Xbase++ Downloads
LOCAL nSuccess
LOCAL oHttp
LOCAL oSbResponseBody
LOCAL oJResp
LOCAL nRespStatusCode
LOCAL cId
LOCAL cName
LOCAL cV_type
LOCAL cContentType
LOCAL cDescription
LOCAL cCreatedAt
LOCAL cUpdatedAt
LOCAL cSha256
LOCAL cWorkspace
LOCAL cCreator
LOCAL nV_protected
LOCAL nPosition
LOCAL cParent
LOCAL i
LOCAL nCount_i
nSuccess := 0
// This example assumes the Chilkat API to have been previously unlocked.
// See Global Unlock Sample for sample code.
oHttp := CreateObject("Chilkat.Http")
// Implements the following CURL command:
// curl --location --request GET 'https://staging-api.yousign.com/files/{{id}}' \
// --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.
oHttp:AuthToken := "YOUR_API_KEY"
oHttp:SetRequestHeader("Content-Type", "application/json")
oSbResponseBody := CreateObject("Chilkat.StringBuilder")
nSuccess := oHttp:QuickGetSb("https://staging-api.yousign.com/files/XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX", oSbResponseBody)
IF (nSuccess == 0)
? oHttp:LastErrorText
oHttp:destroy()
oSbResponseBody:destroy()
RETURN
ENDIF
oJResp := CreateObject("Chilkat.JsonObject")
oJResp:LoadSb(oSbResponseBody)
oJResp:EmitCompact := 0
? "Response Body:"
? oJResp:Emit()
nRespStatusCode := oHttp:LastStatus
? "Response Status Code = " + Str(nRespStatusCode)
IF (nRespStatusCode >= 400)
? "Response Header:"
? oHttp:LastHeader
? "Failed."
oHttp:destroy()
oSbResponseBody:destroy()
oJResp:destroy()
RETURN
ENDIF
// Sample JSON response:
// (Sample code for parsing the JSON response is shown below)
// {
// "id": "/files/XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX",
// "name": "The best name for my file.pdf",
// "type": "signable",
// "contentType": "application/pdf",
// "description": null,
// "createdAt": "2018-12-07T08:10:21+01:00",
// "updatedAt": "2018-12-07T08:10:21+01:00",
// "sha256": "bb57ae2b2ca6ad0133a699350d1a6f6c8cdfde3cf872cf526585d306e4675cc2",
// "metadata": [
// ],
// "workspace": "/workspaces/XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX",
// "creator": null,
// "protected": false,
// "position": 0,
// "parent": null
// }
// Sample code for parsing the JSON response...
// Use the following online tool to generate parsing code from sample JSON:
// Generate Parsing Code from JSON
cId := oJResp:StringOf("id")
cName := oJResp:StringOf("name")
cV_type := oJResp:StringOf("type")
cContentType := oJResp:StringOf("contentType")
cDescription := oJResp:StringOf("description")
cCreatedAt := oJResp:StringOf("createdAt")
cUpdatedAt := oJResp:StringOf("updatedAt")
cSha256 := oJResp:StringOf("sha256")
cWorkspace := oJResp:StringOf("workspace")
cCreator := oJResp:StringOf("creator")
nV_protected := oJResp:BoolOf("protected")
nPosition := oJResp:IntOf("position")
cParent := oJResp:StringOf("parent")
i := 0
nCount_i := oJResp:SizeOfArray("metadata")
DO WHILE i < nCount_i
oJResp:I := i
i := i + 1
ENDDO
oHttp:destroy()
oSbResponseBody:destroy()
oJResp:destroy()