我正在嘗試通過組合服務器上的模板和本地PDF文檔來測試DocuSign。使用DocuSign TemplateReference包裝InlineTemplate需要將有效負載翻倍?
以下代碼有效,但是,我擔心發送的數據量是InlineTemplate
的兩倍。
public virtual TemplateReference CreateInlineTemplate(Recipient[] recipients, AdHocTemplate adHocTemplate, int sequenceId)
{
var templateReference = new TemplateReference();
templateReference.TemplateLocation = TemplateLocationCode.SOAP;
var inlineTemplate = new InlineTemplate
{
Sequence = sequenceId.ToString(CultureInfo.InvariantCulture),
Envelope = new Envelope
{
Recipients = recipients, AccountId = _apiAccountId
}
};
var document = new Document
{
ID = sequenceId.ToString(CultureInfo.InvariantCulture),
Name = string.IsNullOrWhiteSpace(adHocTemplate.Name)
? "Contract " + sequenceId
: adHocTemplate.Name,
PDFBytes = adHocTemplate.Bytes,
FileExtension = ".pdf",
};
// added once
inlineTemplate.Envelope.Documents = new[] { document };
// added twice. Effectively doubled the size of the message.
templateReference.Document = document;
templateReference.Template = SerializeTemplate(inlineTemplate);
templateReference.RoleAssignments = CreateRoleAssignments(recipients).ToArray();
return templateReference;
}
正如你可以看到我創建一個Document
與本地文件,然後將其提供給InlineTemplate
和TemplateReference
。這似乎是讓這個成功發送的唯一方法。
如果我不提供文件的內聯模板,我得到的錯誤:
"Unable to load template. Unable to load template from TemplateReference(1). Error: Object reference not set to an instance of an object"
不將其提供給TemplateReference
,我得到一個錯誤,告訴我,緩衝區不能爲空。
試圖只設置空白文檔失敗,因爲它說文檔不完整。
有沒有辦法讓這個工作沒有發送兩個字節的消息?
我看着做CompositeTemplate
並使用CreateEnvelopeFromTemplatesAndForms()
送它,但是,我需要在服務器上的模板預先填寫的數據,並使用ServerTemplate
不提供一種方法來在自定義字段數據添加。
請問您能分享一個代碼示例嗎?我試圖完成你所做的事情,發現它完全混亂。 – 2016-06-02 04:43:25