DocuSign eSignature REST API v2.1 Java : Document in html format with non English language - docusignapi

I am using eSignature REST API v2.1 Java to create envelope. Document is in html format with non English language. On the signing page these non English is not displayed properly. How to handle this case? Thanks,
String htmlDoc = ".... .... <p>Signera arbetsorderavtal för anställningsnummer</p> ......";
Document document = new Document();
document.setDocumentId("1");
document.setName("name");
document.setDocumentBase64(Base64.getEncoder().encodeToString(htmlDoc));
document.setFileExtension("html");
envelopeDefinition.setDocuments(Arrays.asList(document));
Output:
Expecting proper display of the foreign language.

My code is:
String htmlDoc = "<p>Signera arbetsorderavtal för anställningsnummer</p>"; // removed <html> & <body>
byte[] byteArray = htmlDoc.getBytes(**StandardCharsets.UTF_8**);
Document document = new Document();
document.setDocumentId("1");
document.setName("name");
document.setFileExtension("html");
document.setDocumentBase64(Base64.getEncoder().encodeToString(byteArray));
Output:
Signing Page

You are not telling Java that the string is Unicode Transformation Format or UTF-8.
Here is your code fixed:
String htmlDoc = ".... .... <p>Signera arbetsorderavtal för anställningsnummer</p> ......";
Document document = new Document();
document.setDocumentId("1");
document.setName("name");
document.setDocumentBase64(Base64.getEncoder().encodeToString(htmlDoc.getBytes(StandardCharsets.UTF_8)));
document.setFileExtension("html");
envelopeDefinition.setDocuments(Arrays.asList(document));

Related

Storing and retreiving long strings in XPages

I want to work with long strings (size minimum: 100kb) on Xpages. I assume the best method to store a large string is in a data field of the type "Rich Text".
Right now I am stuck with the data handing of this string. How can I transfer this string between server and client?
So far I tried:
data binding controls: Rich text field (Problem: formats the text, tags), text field (Problem: does not work after a certain size)
implementing a rest service: The response body will be cut off at a certain point
<xe:restService pathInfo="getTestString">
<xe:this.service>
<xe:customRestService>
<xe:this.doGet><![CDATA[#{javascript:var id = context.getUrlParameter("documentId");
session.getCurrentDatabase().getDocumentByID(id).getItemValueString("test");}]]></xe:this.doGet>
</xe:customRestService>
</xe:this.service>
</xe:restService>
var url = new URL(window.location.href);
var documentId = url.searchParams.get("documentId");
xhr.open('GET', './rest.xsp/getTestString?documentId=' + documentId, true);;
xhr.send(null);
xhr.response;
So I was wondering whether I missed out on a configuration of my REST Service. Which other alternatives are available to transfer large data between client and server on Xpages?
I tested your scenario. doc.getItemValueString() only reads 64 KB of data from the rich text field. If you want all data you can use (in SSJS):
var doc = database.getDocumentByUNID(id);
var item:NotesRichTextItem = doc.getFirstItem('test');
return item.getUnformattedText();
Looks like that method return the exact text from the rich text item, no paragraph characters are inserted.

DocuSign connect updates with REST API

I have been using DocuSign SOAP based API service to parse the XML that DocuSign posts for each recipient/envelope status updates.
Within .net web application, here is how I am parsing the XML.
Using sr As New StreamReader(FileName)
Dim xml As String = sr.ReadToEnd()
Dim reader As XmlReader = New XmlTextReader(New StringReader(xml))
Dim serializer As New XmlSerializer(GetType(DocuSignServ.DocuSignEnvelopeInformation), "http://www.docusign.net/API/3.0")
Dim envelopeInfo As DocuSignEnvelopeInformation = TryCast(serializer.Deserialize(reader), DocuSignEnvelopeInformation)
End Using
I would like to know if I can parse the XML with RESTful API here. I could not find a way to convert XML to an object based upon RESTful API.
I tried something like this,
Using sr As New StreamReader(FileName)
Dim xml As String = sr.ReadToEnd()
Dim reader As XmlReader = New XmlTextReader(New StringReader(xml))
Dim serializer As New XmlSerializer(GetType(DocuSign.eSign.Model.EnvelopesInformation), "http://www.docusign.net/API/3.0")
Dim envelopeInfo As DocuSign.eSign.Model.EnvelopesInformation = TryCast(serializer.Deserialize(reader), DocuSign.eSign.Model.EnvelopesInformation)
End Using
I am not able to convert the XML to an envelope object here.
Please advise,
Thanks,
Minal
No, the RESTful API works on different data model and you cannot parse DocuSign Connect XML with RESTful API data model.

What type of data goes into the <PDFBytes> for DocuSign composite templates?

The specific scenario that we are attempting to solve for our API solution is to create an envelope using a template and to replace the template document with a user specified document. DocuSign's documentation on creating a composite template show the steps for the serverside template and inline templates clearly, and this functionality is working correctly for us. However, the portion of the XML string containing the alternate document does not affect the template. Here is the link to DocuSign's example followed by the code snippet regarding document portion of the composite template.
https://www.docusign.com/p/APIGuide/Content/Sending%20Group/Rules%20for%20CompositeTemplate%20Usage.htm
<Document>
<ID>1</ID>
<Name>Form Document</Name>
<PDFBytes>PDF_BYTES_GO_HERE</PDFBytes>
<TransformPdfFields>true</TransformPdfFields>
<FileExtension>pdf</FileExtension>
</Document>
We have tried multiple variations of breaking down the pdf into bytes to insert into the "PDF_BYTES_GO_HERE" portion.
Here is the code we used to get the pdf bytes, convert them to a string and insert into the tag.
Dim fs As FileStream
fs = File.Open(filePath, FileMode.Open)
Dim bytes As Byte() = New Byte(fs.Length - 1) {}
fs.Read(bytes, 0, System.Convert.ToInt32(fs.Length))
fs.Close()
Dim byteString As String = System.Convert.ToBase64String(bytes, 0, bytes.Length)
byteString is the string that we then use in the XML string.
"<Document>" & _
"<documentId>1</documentId>" & _
"<name>DOCUSIGN API TEST</name>" & _
"<PDFBytes>" & byteString & "</PDFBytes>" & _
"<TransformPdfFields>false</TransformPdfFields>" & _
"<FileExtension>pdf</FileExtension>" & _
"</Document>" & _
What type of data is expected within the tag and what is the best way to convert a pdf into that data?
Based on the documentation you've linked to, and the code sample you included, it seems as though you're using the DocuSign SOAP API. If that's the case, then the DocuSign SOAP API guide will be a useful reference for you. As the guide specifies, the PDFBytes property expects a base64-encoded byte stream that represents the document contents:
Are you manually constructing the XML payload? If so, you might instead want to consider adding a Service Reference to your project for the DocuSign WSDL, and then using the proxy classes (i.e., DocuSign object model) that come from that to construct the payload and subsequently send the envelope. If you go this route, the API guide contains code examples in a couple different languages that illustrate the setting of the PDFBytes property during Envelope creation -- starting on page 62. For example:
C#
// Attach the document(s)
envelope.Documents = new DocuSignWeb.Document[1];
DocuSignWeb.Document doc = new DocuSignWeb.Document();
doc.ID = "1";
doc.Name = "Document Name";
doc.PDFBytes = [Location of Document];
envelope.Documents[0] = doc;
PHP
// Attach the document
$doc = new Document();
$doc->ID = "1";
$doc->Name = "Picture PDF";
$doc->PDFBytes = file_get_contents("docs/picturePdf.pdf");
$env->Documents = array($doc);
Perhaps try modeling your approach after one of these examples (in VB, rather than C# or PHP)?

Parse attribute of Media Element

I want to parse url attribute from the XML and show image in image control (the one reffered to by the URL) in listbox from the following feed link: http://feeds.bbci.co.uk/news/rss.xml
My code is:
var ComingNewsFromUri = from rss in XElement.Parse(e.Result).Descendants("item")
select new NewsItems
{
Title = rss.Element("title").Value,
PubDate = rss.Element("pubDate").Value,
Description = rss.Element("description").Value
};
For RSS, I would recommend using SyndicationFeed and SyndicationItem....does all the parsing and converting to objects automatically and brilliantly for you.
http://ryanhayes.net/blog/how-to-build-an-rss-feed-reader-in-windows-phone-7part-i-retrieving-parsing-and-displaying-post-titles/
I have an RSS feed app on the store myself using SyndicationFeed and it is very reliable and convenient.
Here is another sample by Microsoft
http://code.msdn.microsoft.com/wpapps/RSS-Reader-Sample-1702775f

How to Get the Title of a SharePoint List?

I am trying to retrieve a list from SharePoint using the web services. I ran into the problem described in this blog post, i.e. the GetList method apparently expects to be passed the list's title instead of the list's name (even though the parameter is called "listName"). I have the list's name, but I cannot figure out how to get the list's title. Where can I find that?
I'm using the SharePoint in Office 365, which I believe is 2010.
A little over head but try this code. Its just a sample code, you might want to mould it to your logic.
string listName = "MyList";
Lists.Lists listSvc = new Lists.Lists();
listSvc.UseDefaultCredentials = true;
XmlDocument xDoc = new XmlDocument();
xDoc.LoadXml(listSvc.GetListCollection().OuterXml);
XmlNamespaceManager nsmgr = new XmlNamespaceManager(xDoc.NameTable);
nsmgr.AddNamespace("A", "http://schemas.microsoft.com/sharepoint/soap/");
XmlNode requiredList = xDoc.SelectSingleNode("//A:List[contains(#DefaultViewUrl,'" + listName + "')]", nsmgr);
string listTitle = requiredList.Attributes["Title"].Value;
XmlNode list = listSvc.GetList(listTitle);
strListName: Can be either a list name, such as "Documents", or a GUID of the list, with or without curly braces, in the following format:
{318B9E8F-1EF4-4D49-9773-1BD2976772B6}
you may find more info here - the above info is an excerpt from this document

Resources