To download all your documents using the API, we recommend looping through all the pages of the List Signature Requests endpoint to obtain all the signature_request_ids. Then loop through the list of signature_request_ids to download each document using the Get Files endpoint.
Here's an example using the Ruby SDK:
1. Initiate
Sign with your account's API Key.require 'dropbox_sign'
Dropbox::Sign.configure do |config|
# Configure HTTP basic authorization: api_key
config.username = "YOUR_API_KEY"
# or, configure Bearer (JWT) authorization: oauth2
# config.access_token = "YOUR_ACCESS_TOKEN"
end
2. Obtain the total number of pages of signature requests returned from the list signature requests endpoint and loop through the pages of the signature requests to combine into one list.
def get_all_signature_requests
signature_request_api = Dropbox::Sign::SignatureRequestApi.new
page_size=100
result = signature_request_api.signature_request_list({page_size: page_size})
total_pages = result.list_info.num_pages
signature_requests=[]
total_pages.times do |page_number|
result = signature_request_api.signature_request_list({page_size: page_size, page_number:page_number+1})
signature_requests += result.signature_requests
end
3.
puts signature_requests.size
puts signature_requests.map {|s| s.signature_request_id}
signature_requests
end
4. Loop through all signature requests and download the completed documents.
def download_requests(requests)
signature_request_api = Dropbox::Sign::SignatureRequestApi.new
requests.each do |req|
file_bin = signature_request_api.signature_request_files(req.signature_request_id,{file_type:"pdf"})
FileUtils.cp(file_bin.path, "/path/to/your/file#{req.signature_request_id}.pdf")
end
end
download_requests(get_all_signature_requests())
Comments
0 comments
Article is closed for comments.