PowerBuilder
PowerBuilder
DocuSign List Envelope Documents
See more DocuSign Examples
Retrieve a list of all documents within a specific envelope.Chilkat PowerBuilder Downloads
integer li_rc
integer li_Success
oleobject loo_Http
oleobject loo_JsonToken
oleobject loo_SbResponseBody
oleobject loo_JResp
integer li_RespStatusCode
string ls_DocumentId
string ls_DocumentIdGuid
string ls_Name
string ls_V_type
string ls_Uri
string ls_Order
string ls_Display
string ls_IncludeInDownload
string ls_SignerMustAcknowledge
string ls_TemplateRequired
string ls_AuthoritativeCopy
integer j
integer li_Count_j
string ls_PageId
string ls_Sequence
string ls_Height
string ls_Width
string ls_Dpi
string ls_IsDefault
string ls_EnvelopeId
integer i
integer li_Count_i
li_Success = 0
// This example assumes the Chilkat API to have been previously unlocked.
// See Global Unlock Sample for sample code.
loo_Http = create oleobject
li_rc = loo_Http.ConnectToNewObject("Chilkat.Http")
if li_rc < 0 then
destroy loo_Http
MessageBox("Error","Connecting to COM object failed")
return
end if
// Implements the following HTTP request:
// GET /restapi/v2.1/accounts/{accountId}/envelopes/{envelopeId}/documents
// Adds the "Authorization: Bearer eyJ0eXAi.....UE8Kl_V8KroQ" header.
loo_JsonToken = create oleobject
li_rc = loo_JsonToken.ConnectToNewObject("Chilkat.JsonObject")
// Load a previously obtained OAuth2 access token.
li_Success = loo_JsonToken.LoadFile("qa_data/tokens/docusign.json")
if li_Success = 0 then
Write-Debug loo_JsonToken.LastErrorText
destroy loo_Http
destroy loo_JsonToken
return
end if
loo_Http.AuthToken = loo_JsonToken.StringOf("access_token")
// Use your account ID and a valid envelopeId here:
loo_Http.SetUrlVar("accountId","7f3f65ed-5e87-418d-94c1-92499ddc8252")
loo_Http.SetUrlVar("envelopeId","90d7e40a-b4bd-4ccd-bf38-c80e37954a13")
loo_SbResponseBody = create oleobject
li_rc = loo_SbResponseBody.ConnectToNewObject("Chilkat.StringBuilder")
li_Success = loo_Http.QuickGetSb("https://demo.docusign.net/restapi/v2.1/accounts/{$accountId}/envelopes/{$envelopeId}/documents",loo_SbResponseBody)
if li_Success = 0 then
Write-Debug loo_Http.LastErrorText
destroy loo_Http
destroy loo_JsonToken
destroy loo_SbResponseBody
return
end if
loo_JResp = create oleobject
li_rc = loo_JResp.ConnectToNewObject("Chilkat.JsonObject")
loo_JResp.LoadSb(loo_SbResponseBody)
loo_JResp.EmitCompact = 0
Write-Debug "Response Body:"
Write-Debug loo_JResp.Emit()
li_RespStatusCode = loo_Http.LastStatus
Write-Debug "Response Status Code = " + string(li_RespStatusCode)
if li_RespStatusCode >= 400 then
Write-Debug "Response Header:"
Write-Debug loo_Http.LastHeader
Write-Debug "Failed."
destroy loo_Http
destroy loo_JsonToken
destroy loo_SbResponseBody
destroy loo_JResp
return
end if
// Sample JSON response:
// (Sample code for parsing the JSON response is shown below)
// {
// "envelopeId": "90d7e40a-b4bd-4ccd-bf38-c80e37954a13",
// "envelopeDocuments": [
// {
// "documentId": "1",
// "documentIdGuid": "ca1d3cc6-9bc3-48d6-a5d8-a85d9acdcde1",
// "name": "helloWorld.pdf",
// "type": "content",
// "uri": "/envelopes/90d7e40a-b4bd-4ccd-bf38-c80e37954a13/documents/1",
// "order": "1",
// "pages": [
// {
// "pageId": "fbf93a36-6b60-484d-94bd-ee3c08c0a546",
// "sequence": "1",
// "height": "842",
// "width": "595",
// "dpi": "72"
// }
// ],
// "availableDocumentTypes": [
// {
// "type": "electronic",
// "isDefault": "true"
// }
// ],
// "display": "inline",
// "includeInDownload": "true",
// "signerMustAcknowledge": "no_interaction",
// "templateRequired": "false",
// "authoritativeCopy": "false"
// },
// {
// "documentId": "certificate",
// "documentIdGuid": "7479a5de-8d91-44a2-bc33-b76a9ba0f6e2",
// "name": "Summary",
// "type": "summary",
// "uri": "/envelopes/90d7e40a-b4bd-4ccd-bf38-c80e37954a13/documents/certificate",
// "order": "999",
// "availableDocumentTypes": [
// {
// "type": "electronic",
// "isDefault": "true"
// }
// ],
// "display": "inline",
// "includeInDownload": "true",
// "signerMustAcknowledge": "no_interaction",
// "templateRequired": "false",
// "authoritativeCopy": "false"
// }
// ]
// }
// Sample code for parsing the JSON response...
// Use the following online tool to generate parsing code from sample JSON:
// Generate Parsing Code from JSON
ls_EnvelopeId = loo_JResp.StringOf("envelopeId")
i = 0
li_Count_i = loo_JResp.SizeOfArray("envelopeDocuments")
do while i < li_Count_i
loo_JResp.I = i
ls_DocumentId = loo_JResp.StringOf("envelopeDocuments[i].documentId")
ls_DocumentIdGuid = loo_JResp.StringOf("envelopeDocuments[i].documentIdGuid")
ls_Name = loo_JResp.StringOf("envelopeDocuments[i].name")
ls_V_type = loo_JResp.StringOf("envelopeDocuments[i].type")
ls_Uri = loo_JResp.StringOf("envelopeDocuments[i].uri")
ls_Order = loo_JResp.StringOf("envelopeDocuments[i].order")
ls_Display = loo_JResp.StringOf("envelopeDocuments[i].display")
ls_IncludeInDownload = loo_JResp.StringOf("envelopeDocuments[i].includeInDownload")
ls_SignerMustAcknowledge = loo_JResp.StringOf("envelopeDocuments[i].signerMustAcknowledge")
ls_TemplateRequired = loo_JResp.StringOf("envelopeDocuments[i].templateRequired")
ls_AuthoritativeCopy = loo_JResp.StringOf("envelopeDocuments[i].authoritativeCopy")
j = 0
li_Count_j = loo_JResp.SizeOfArray("envelopeDocuments[i].pages")
do while j < li_Count_j
loo_JResp.J = j
ls_PageId = loo_JResp.StringOf("envelopeDocuments[i].pages[j].pageId")
ls_Sequence = loo_JResp.StringOf("envelopeDocuments[i].pages[j].sequence")
ls_Height = loo_JResp.StringOf("envelopeDocuments[i].pages[j].height")
ls_Width = loo_JResp.StringOf("envelopeDocuments[i].pages[j].width")
ls_Dpi = loo_JResp.StringOf("envelopeDocuments[i].pages[j].dpi")
j = j + 1
loop
j = 0
li_Count_j = loo_JResp.SizeOfArray("envelopeDocuments[i].availableDocumentTypes")
do while j < li_Count_j
loo_JResp.J = j
ls_V_type = loo_JResp.StringOf("envelopeDocuments[i].availableDocumentTypes[j].type")
ls_IsDefault = loo_JResp.StringOf("envelopeDocuments[i].availableDocumentTypes[j].isDefault")
j = j + 1
loop
i = i + 1
loop
destroy loo_Http
destroy loo_JsonToken
destroy loo_SbResponseBody
destroy loo_JResp