I am creating an embedded solution. At some point in my app, the user can upload a file. I have a required attachment field in my template. If the user uploaded a file in my app, I want to attach it during envelope creation, otherwise I want the docusign signing view to force attachment. In either case, I want it to appear identical to the user receiving the final signed document (ie: as a separate attachment). I'm looking for XML examples of how to achieve this. This post had a recommended solution similar to what I'm looking to do, but there was no code: Attachments on iPad in iFrame docusign and this post referred to an example that might be what I want, but the link is broken: What is expected for the EnvelopeAttachment parameters of "Type" and "Label"?
or if someone could point me to the current location of:
http://www.docusign.com/content/e-signature-code-walkthrough-signer-attachments
Non-working example of what I'm looking for:
public void AddAttachment2Envelope(string envelopeID, byte[] attachment, string attachmentname)
{
string url = baseURL + "/envelopes/" + envelopeID + "/documents";
string requestBody =
"--AAA" + "\r\n" +
"Content-Type: application/xml" + "\r\n" +
"Content-Disposition: form-data" + "\r\n" +
"<envelopeDefinition xmlns=\"http://www.docusign.com/restapi\">" + "\r\n" +
"<documents>" + "\r\n" +
"<document>" + "\r\n" +
"<documentId>12345</documentId>" + "\r\n" + //what is documentid here used for?
"<name>" + attachmentname + "</name>" + "\r\n" +
"<order>1</order>" + "\r\n" +
"</document>" + "\r\n" +
"</documents>" + "\r\n" +
"</envelopeDefinition>" + "\r\n" +
"--AAA" + "\r\n" +
"Content-Type: application/pdf" + "\r\n" +
"Content-Disposition: file; filename=\"String content\"; documentId=10" + "\r\n" + //what is documentid here used for?
attachment.ToString() + "\r\n" +
"--AAA";
HttpWebRequest request = initializeRequest(url, "PUT", requestBody, email, password);
request.ContentType = "multipart/form-data; boundary=AAA";
string response = getResponseBody(request);
}
I've also tried the following without success:
public void AddAttachment2Envelope(string envelopeID, byte[] attachment, string attachmentname, Boolean bad)
{
string ctype = "Content-Type: application/pdf";
if (attachmentname.ToLower().EndsWith(".jpg"))
ctype = "Content-Type: image/jpeg";
else if (attachmentname.ToLower().EndsWith(".png"))
ctype = "Content-Type: image/png";
string url = baseURL + "/envelopes/" + envelopeID + "/documents/10";
string requestBody =
ctype + "\r\n" +
"Content-Disposition: file; filename=\"" + attachmentname + "\"; documentId=10" + "\r\n" +
System.Text.Encoding.Default.GetString(attachment) + "\r\n" + //System.Text.Encoding.Default.GetString(attachment) //System.Convert.ToBase64String(attachment, 0, attachment.Length)
"";
HttpWebRequest request = initializeRequest(url, "PUT", requestBody, email, password);
request.ContentType = ctype.Replace("Content-Type: ", "");
request.Headers.Add("Content-Disposition", "file; filename=\"" + attachmentname + "\"; documentId=10");
string response = getResponseBody(request);
}
public void AddAttachment2Envelope(string envelopeID, byte[] attachment, string attachmentname)
{
string ctype = "Content-Type: application/pdf";
if (attachmentname.ToLower().EndsWith(".jpg"))
ctype = "Content-Type: image/jpeg";
else if (attachmentname.ToLower().EndsWith(".png"))
ctype = "Content-Type: image/png";
string url = baseURL + "/envelopes/" + envelopeID + "/documents";
string requestBody =
"--AAA" + "\r\n" +
"Content-Type: application/xml" + "\r\n" +
"Content-Disposition: form-data" + "\r\n" +
//"<envelopeDefinition xmlns=\"http://www.docusign.com/restapi\">" + "\r\n" +
//"<documents>" + "\r\n" +
"<document>" + "\r\n" +
"<documentId>10</documentId>" + "\r\n" +
"<name>" + attachmentname + "</name>" + "\r\n" +
"<order>2</order>" + "\r\n" +
//"<FileExtension>" + System.IO.Path.GetExtension(attachmentname).Replace(".", "").ToLower() + "</FileExtension>" + "\r\n" +
"</document>" + "\r\n" +
//"</documents>" + "\r\n" +
//"</envelopeDefinition>" + "\r\n" +
"--AAA" + "\r\n" +
ctype + "\r\n" +
"Content-Disposition: file; filename=\"" + attachmentname + "\"; documentId=10" + "\r\n" +
System.Convert.ToBase64String(attachment, 0, attachment.Length) + "\r\n" + //System.Text.Encoding.Default.GetString(attachment)
"--AAA--";
HttpWebRequest request = initializeRequest(url, "PUT", requestBody, email, password);
request.ContentType = "multipart/form-data; boundary=AAA";
//request.Accept = "multipart/form-data;";
string response = getResponseBody(request);
}
public void AddAttachment2Envelope(string envelopeID, byte[] attachment, string attachmentname, int bad)
{
string url = baseURL + "/envelopes/" + envelopeID + "/documents";
string requestBody =
// "<envelopeDefinition xmlns=\"http://www.docusign.com/restapi\">" + "\r\n" +
// "<documents>" + "\r\n" +
"<document>" + "\r\n" +
"<documentId>10</documentId>" + "\r\n" +
"<name>" + attachmentname + "</name>" + "\r\n" +
"<order>2</order>" + "\r\n" +
"<FileExtension>" + System.IO.Path.GetExtension(attachmentname).Replace(".", "").ToLower() + "</FileExtension>" + "\r\n" +
"<documentBase64>" + System.Convert.ToBase64String(attachment, 0, attachment.Length) + "</documentBase64>" + "\r\n" +
"</document>" + "\r\n" +
// "</documents>" + "\r\n" +
// "</envelopeDefinition>" + "\r\n" +
"";
//requestBody = requestBody.Replace("\r\n", "");
HttpWebRequest request = initializeRequest(url, "PUT", requestBody, email, password);
string response = getResponseBody(request);
}