Docusign-打开通过Rest API下载的PDF时出错 [英] Docusign - Error opening PDF downloaded through the Rest API
问题描述
使用REST API,我试图从完整的信封中取出文档。我的标头使用X-DocuSign-Authentication。
EnvelopesApi ap = new EnvelopesApi();
编码encoding = System.Text.Encoding.GetEncoding( utf-8);
EnvelopeDocumentsResult edr = ap.ListDocuments((AccountId, xxx-xx-xxx);
List< EnvelopeDocument> docs = edr.EnvelopeDocuments;
foreach(文档中的EnvelopeDocument doc)
{
Stream stream1 = ap.GetDocument(AccountId, xxx-xx-xxx,doc.DocumentId);
StreamReader阅读器=新系统.IO.StreamReader(stream1,encoding);
var data = reader.ReadToEnd();
StreamWriter writer = new StreamWriter(@ C:\mysigneddoc.pdf);
writer .write(data);
writer.Close();
}
尝试打开完整的pdf时,出现错误,指出
签名人身份尚未得到验证。
有什么想法可能会出错吗?
var ap = new EnvelopesApi( );
var edr = ap.ListDocuments((AccountId, xxx-xx-xxx);
List< EnvelopeDocument> docs = edr.EnvelopeDocuments;
foreach(EnvelopeDocument doc in docs)
{
// API调用GetDocument()返回一个MemoryStream
var docStream =(MemoryStream)envelopesApi.GetDocument(accountId,envelopeId,doc.DocumentId);
//让我们将文档保存到本地文件系统
filePath = @ C:\temp\ + Path.GetRandomFileName()+ .pdf;
fs = new FileStream(filePath,FileMode.Create );
docStream.Seek(0,SeekOrigin.Begin);
docStream.CopyTo(fs);
fs.Close();
}
您还可以使用 GetEnvelopeDocuments api。您无需查询每个文档。
- 组合PDF
传递字符串 combined 作为documentId。
检索包含所有文档和证书的组合内容的PDF。
字符串信封ID = XXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX;
字符串accountId = XXXXXX;
var envApi = new EnvelopesApi();
// GetDocument()API调用返回MemoryStream
var docStream =(MemoryStream)envApi.GetDocument(accountId,envelopeId, combined);
//将文档保存到本地文件系统
字符串filePath = @ C:\temp\ + Path.GetRandomFileName()+ .pdf;
var fs = new FileStream(filePath,FileMode.Create);
docStream.Seek(0,SeekOrigin.Begin);
docStream.CopyTo(fs);
fs.Close();
- ZIP文件
将字符串 archive 作为documentId传递
检索包含所有PDF文档,证书以及用于语音身份验证的任何.WAV文件的ZIP存档。
var envApi = new EnvelopesApi();
// GetDocument()API调用返回MemoryStream
var docStream =(FileStream)envApi.GetDocument(accountId,envelopeId, archive);
//将文档保存到本地文件系统
字符串filePath = @ C:\temp\ + Path.GetRandomFileName()+ .zip;
var fs = new FileStream(filePath,FileMode.Create);
docStream.Seek(0,SeekOrigin.Begin);
docStream.CopyTo(fs);
fs.Close();
With the REST api, I am trying to get the documents out of a completed envelope. My header is using X-DocuSign-Authentication.
EnvelopesApi ap = new EnvelopesApi();
Encoding encode = System.Text.Encoding.GetEncoding("utf-8");
EnvelopeDocumentsResult edr = ap.ListDocuments((AccountId, "xxx-xx-xxx");
List<EnvelopeDocument> docs = edr.EnvelopeDocuments;
foreach(EnvelopeDocument doc in docs)
{
Stream stream1 = ap.GetDocument(AccountId, "xxx-xx-xxx", doc.DocumentId);
StreamReader reader = new System.IO.StreamReader(stream1, encode);
var data = reader.ReadToEnd();
StreamWriter writer = new StreamWriter(@"C:\mysigneddoc.pdf");
writer.Write(data);
writer.Close();
}
When I try to open the completed pdf, I get the error stating that
the signers identity has not been verified.
Any ideas where I might be going wrong?
Please look at the API recipe here to download the documents from an envelope.
var ap = new EnvelopesApi();
var edr = ap.ListDocuments((AccountId, "xxx-xx-xxx");
List<EnvelopeDocument> docs = edr.EnvelopeDocuments;
foreach(EnvelopeDocument doc in docs)
{
// GetDocument() API call returns a MemoryStream
var docStream = (MemoryStream)envelopesApi.GetDocument(accountId, envelopeId, doc.DocumentId);
// let's save the document to local file system
filePath = @"C:\temp\" + Path.GetRandomFileName() + ".pdf";
fs = new FileStream(filePath, FileMode.Create);
docStream.Seek(0, SeekOrigin.Begin);
docStream.CopyTo(fs);
fs.Close();
}
You can also download the combined documents in an envelope using the GetEnvelopeDocuments api. You are not required to query for each individual document.
- Combined PDF
Pass the string combined as the documentId.
Retrieve a PDF that contains the combined content of all documents and the certificate.
string envelopeId = "XXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX";
string accountId = "XXXXXX";
var envApi = new EnvelopesApi();
// GetDocument() API call returns a MemoryStream
var docStream = (MemoryStream)envApi.GetDocument(accountId, envelopeId, "combined");
// let's save the document to local file system
string filePath = @"C:\temp\" + Path.GetRandomFileName() + ".pdf";
var fs = new FileStream(filePath, FileMode.Create);
docStream.Seek(0, SeekOrigin.Begin);
docStream.CopyTo(fs);
fs.Close();
- ZIP file
Pass the string archive as documentId
Retrieve a ZIP archive that contains all of the PDF documents, the certificate, and any .WAV files used for voice authentication.
var envApi = new EnvelopesApi();
// GetDocument() API call returns a MemoryStream
var docStream = (FileStream)envApi.GetDocument(accountId, envelopeId, "archive");
// let's save the document to local file system
string filePath = @"C:\temp\" + Path.GetRandomFileName() + ".zip";
var fs = new FileStream(filePath, FileMode.Create);
docStream.Seek(0, SeekOrigin.Begin);
docStream.CopyTo(fs);
fs.Close();
这篇关于Docusign-打开通过Rest API下载的PDF时出错的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!