rabraham | Posts: 9

Creating the template or package give error

0 votes
I took the sample code .net code (c#) from online and was getting the below error when creating a template and package. "Could not create template. Exception: Error communicating with esl server. Invalid URI: The format of the URI could not be determined."

harishaidary | Posts: 1812

Reply to: Creating the template or package give error

0 votes
Can you post the link where you got the sample code from? Thanks,

rabraham | Posts: 9

Reply to: Creating the template or package give error

0 votes
Hi Haris, I took the code from https://www.esignlive.com/blog/esignlive-how-to-creating-a-template/ I also downloaded the SDK samples and tried the code. I am new to eSign. My requirement is to write a custom app(C#) that will upload the document to eSign and then monitor if the document has been signed and after it has been signed download the whole package. Thanks, Raji

harishaidary | Posts: 1812

Reply to: Creating the template or package give error

0 votes

Can you try changing the base url to "https://sandbox.e-signlive.com/api" (notice the dash in e-signlive) and see if it works? I think it might be the culprit here. Regarding your requirements:

  • You can grab the signer status by setting up callbacks event notifications or from the audit trail. More information about this here: https://community.onespan.com/forum/signer-status
  • Here's sample code on how you would download your signed documents:
    byte[] zipContent = client.DownloadZippedDocuments (packageId);
    File.WriteAllBytes (Directory.GetCurrentDirectory() + "/package-documents.zip", zipContent);

rabraham | Posts: 9

Reply to: Creating the template or package give error

0 votes
public PackageId CreateTemplate() { EslClient eslclient = new EslClient("APIKEY", "https://sandbox.e-signlive.com/api"); string SignDocPath = @"C:\Projects\DigitalSign\SampleCode\GISOnline\GISOnline\Files\Curb Ramp Inspection Form for IT - Copy1.pdf"; Stream fileStream1; fileStream1 = File.OpenRead(SignDocPath); DocumentPackage documentPackage = Silanis.ESL.SDK.Builder.PackageBuilder.NewPackageNamed("ADARampInspectionFormTemp") .WithSigner(SignerBuilder.NewSignerPlaceholder(new Placeholder("PlaceholderId1"))) //.WithSigner(SignerBuilder.NewSignerPlaceholder(new Placeholder("PlaceholderId2"))) .WithDocument(DocumentBuilder.NewDocumentNamed("First Document") .FromStream(fileStream1, DocumentType.PDF) .WithSignature(SignatureBuilder.SignatureFor(new Placeholder("PlaceholderId1")) .OnPage(1) .AtPosition(100, 140)) ) .Build(); PackageId templateId = eslclient.CreateTemplate(documentPackage); return templateId; } I have attached my code to create a template and then use it for creating the package. Do you see anything wrong in the code? Another question, if I created a template using the web interface and added the placeholders for signature, name and date. Can I call this template in my custom code to create the package? If yes do have an sample code?

harishaidary | Posts: 1812

Reply to: Creating the template or package give error

0 votes
I don't see anything wrong in your code but there are a couple things I should point out:
  1. can you make sure you are registered on US sandbox? In other words, when you log into your sandbox account, are you on .com or .ca? And change the base url accordingly if you are on canadian sandbox.
  2. page index starts at 0. So if you only have a single page on your document, it will throw an error if you do .OnPage(1).
You can definitely create your template from the web ui and then create your package programmatically. To do this you will you need to grab the id of your template which you can find in the url when you browse to your template in the web ui (e.g. https://sandbox.e-signlive.com/packages/{templateId}).
PackageId templateId = new PackageId("{templateId}");
DocumentPackage newPackage = PackageBuilder.NewPackageNamed(PackageName)
                .DescribedAs(PACKAGE_DESCRIPTION)
                    .WithEmailMessage(PACKAGE_EMAIL_MESSAGE)
                    .WithSigner(SignerBuilder.NewSignerWithEmail(email2)
                                .WithFirstName(PACKAGE_SIGNER_FIRST)
                                .WithLastName(PACKAGE_SIGNER_LAST).Replacing(new Placeholder(PLACEHOLDER_ID)))
                    .WithSettings(DocumentPackageSettingsBuilder.NewDocumentPackageSettings().WithInPerson())
                    .Build();

PackageId packageId = eslClient.CreatePackageFromTemplate(templateId, newPackage);

harishaidary | Posts: 1812

Reply to: Creating the template or package give error

0 votes
Also, are you able to do anything else with the SDK (e.g. a simple create and send a package) or is it just creating templates that is not working for you?

rabraham | Posts: 9

Reply to: Creating the template or package give error

0 votes
I created the template and copied the code you posted. Don't we need to upload the file with the package? Each file will be different, it uses the same template but may have different field values.

rabraham | Posts: 9

Reply to: Creating the template or package give error

0 votes
I still get the same error "{"Error communicating with esl server. Invalid URI: The format of the URI could not be determined."}", my code EslClient eslclient = new EslClient(APIKey, APIUrl); string email1 = "[email protected]"; string SignDocPath = @"C:\Projects\DigitalSign\SampleCode\GISOnline\GISOnline\Files\42891.pdf"; string packageid = "b8fe3288-822d-4128-859c-a702450cdd5a"; Stream fileStream1; fileStream1 = File.OpenRead(SignDocPath); DocumentPackage newPackage = Silanis.ESL.SDK.Builder.PackageBuilder.NewPackageNamed("ADARampInspection:" + DateTime.Now) .DescribedAs("ADA Ramp Inspection") //.WithEmailMessage(PACKAGE_EMAIL_MESSAGE2) .WithSigner(Silanis.ESL.SDK.Builder.SignerBuilder.NewSignerWithEmail(email1) .WithFirstName("Raji") .WithLastName("Abraham") .WithTitle("Reviewer") .WithCompany("City Of Sacramento") .WithCustomId("Signer1")) .WithSettings(DocumentPackageSettingsBuilder.NewDocumentPackageSettings() .WithoutInPerson()) //.WithoutDecline() //.WithoutOptOut() //.WithWatermark() //.Build()) .WithDocument(DocumentBuilder.NewDocumentNamed("First Document") .FromStream(fileStream1, DocumentType.PDF)) .Build(); PackageId templateId = new PackageId(packageid); PackageId packageId = eslclient.CreatePackageFromTemplate(templateId, newPackage); //Error at this line DocumentPackage retrievedPackage = eslclient.GetPackage(packageId); eslclient.SendPackage(packageId);

rabraham | Posts: 9

Reply to: Creating the template or package give error

0 votes
I tried creating a simple package. I get the same error. EslClient eslclient = new EslClient(APIKey, APIUrl); string email1 = "[email protected]"; string SignDocPath = @"C:\Projects\DigitalSign\SampleCode\GISOnline\GISOnline\Files\42891.pdf"; Stream fileStream1; fileStream1 = File.OpenRead(SignDocPath); DocumentPackage newPackage = Silanis.ESL.SDK.Builder.PackageBuilder.NewPackageNamed("ADARampInspection:" + DateTime.Now) .DescribedAs("ADA Ramp Inspection") .WithSigner(Silanis.ESL.SDK.Builder.SignerBuilder.NewSignerWithEmail(email1) .WithFirstName("Raji") .WithLastName("Abraham") .WithTitle("Reviewer") .WithCompany("City Of Sacramento") .WithCustomId("Signer1")) .WithDocument( DocumentBuilder.NewDocumentNamed( "First Document" ) .FromStream( fileStream1, DocumentType.PDF ) .WithSignature( SignatureBuilder.SignatureFor( email1 ) .OnPage( 1 ) .AtPosition(100,300) )) .Build(); PackageId packageId = eslclient.CreatePackage(newPackage); eslclient.SendPackage(packageId); The document has 2 pages and the signature should be on the second page.

rabraham | Posts: 9

Reply to: Creating the template or package give error

0 votes
I fixed the problem. I was passing the wrong key. I am getting this error now {"Could not send the package. Exception: The remote server returned an error: (400) Bad Request. HTTP POST on URI https://sandbox.e-signlive.com/api/packages/bae77cc8-d67c-4f4d-a0f6-d2144c939af2. Optional details: {\"entity\":null,\"technical\":null,\"packageId\":null,\"messageKey\":\"error.validation.packageActivation.unassignedRole\",\"message\":\"There is a role with no signer.\",\"code\":400,\"name\":\"Validation Error\"}"}

harishaidary | Posts: 1812

Reply to: Creating the template or package give error

1 votes
Hey Raji, I just had a look at the package you are trying to send on my end and the reason you're not able to send that package is because you are trying to send a package with a placeholder. This of course will not work as per the 400 error you are getting above. The reason for this is because when you create a template with placeholders from the web ui, eSignLive will assign random generated IDs (not the same as the name) to your placeholder. Therefore, in order for this line to work
.Replacing(new Placeholder(PLACEHOLDER_ID))
in the code I shared, you will need to retrieve the placeholder id first. Here is a complete example on how you would create a template and then create a package from that template and replacing the placeholder with a signer through the SDK:
using System;
using System.IO;
using Silanis.ESL.SDK;
using Silanis.ESL.SDK.Builder;

namespace createTemplateFrom
{
    class createTemplateFrom
    {
        private static String APIUrl = "https://sandbox.e-signlive.com/api";
        private static String APIKey = "your_api_key_here";

        public static PackageId templateId;
        public static PackageId packageId;

        public static string DOCUMENT_NAME = "First Document";
        public static string DOCUMENT_ID = "doc1";
        public static string TEMPLATE_NAME = "CreatePackageFromTemplateWithReplacingPlaceholderExample Template: " + DateTime.Now;
        public static string TEMPLATE_DESCRIPTION = "This is a template created using the e-SignLive SDK";
        public static string TEMPLATE_EMAIL_MESSAGE = "This message should be delivered to all signers";
        public static string TEMPLATE_SIGNER_FIRST = "John";
        public static string TEMPLATE_SIGNER_LAST = "Smith";
        public static string email1 = "[email protected]";

        public static string PACKAGE_DESCRIPTION = "This is a package created using the e-SignLive SDK";
        public static string PACKAGE_EMAIL_MESSAGE = "This message should be delivered to all signers";
        public static string PACKAGE_SIGNER_FIRST = "Patty";
        public static string PACKAGE_SIGNER_LAST = "Galant";
        public static string email2 = "[email protected]";

        public static string PLACEHOLDER_ID = "PlaceholderId1";

        public static void Main(string[] args)
        {
            EslClient eslClient = new EslClient(APIKey, APIUrl);

            Stream fileStream1 = File.OpenRead(@"DOC_FILE_PATH");

            //Create template with one signer and one placeholder
            DocumentPackage template = PackageBuilder.NewPackageNamed(TEMPLATE_NAME)
                .DescribedAs(TEMPLATE_DESCRIPTION)
                    .WithEmailMessage(TEMPLATE_EMAIL_MESSAGE)
                    .WithSigner(SignerBuilder.NewSignerWithEmail(email1)
                                .WithFirstName(TEMPLATE_SIGNER_FIRST)
                                .WithLastName(TEMPLATE_SIGNER_LAST))
                    .WithSigner(SignerBuilder.NewSignerPlaceholder(new Placeholder(PLACEHOLDER_ID)))
                    .WithDocument(DocumentBuilder.NewDocumentNamed(DOCUMENT_NAME)
                                  .WithId(DOCUMENT_ID)
                                  .FromStream(fileStream1, DocumentType.PDF)
                                  .WithSignature(SignatureBuilder.SignatureFor(email1)
                                   .OnPage(0)
                                   .AtPosition(100, 100))
                                  .WithSignature(SignatureBuilder.SignatureFor(new Placeholder(PLACEHOLDER_ID))
                                   .OnPage(0)
                                   .AtPosition(400, 100)))
                    .Build();

            templateId = eslClient.CreateTemplate(template);

            //Create package from template and replacing placeholder with signer
            DocumentPackage newPackage = PackageBuilder.NewPackageNamed("Test")
                .DescribedAs(PACKAGE_DESCRIPTION)
                    .WithEmailMessage(PACKAGE_EMAIL_MESSAGE)
                    .WithSigner(SignerBuilder.NewSignerWithEmail(email2)
                                .WithFirstName(PACKAGE_SIGNER_FIRST)
                                .WithLastName(PACKAGE_SIGNER_LAST).Replacing(new Placeholder(PLACEHOLDER_ID)))
                    .WithSettings(DocumentPackageSettingsBuilder.NewDocumentPackageSettings().WithInPerson())
                    .Build();

            packageId = eslClient.CreatePackageFromTemplate(templateId, newPackage);
        }
    }
}
Templates are useful if you're planning on sending the same document over and over again and only replacing your placeholder(s) with your signers. If you plan on uploading a different document every time, then there is really no need to create a template. You can just create a new package and send it for signing. Let me know if anything is unclear :)

shravanpolisetty | Posts: 5

Reply to: Creating the template or package give error

0 votes
Hey Harishaidary, So I just tried your code using the Java SDK. I am able to create the template with the placeholder and replace the placeholder. But im getting an error while sending the package. Could not send the package. Exception: HTTP POST on URI https://sandbox.esignlive.com/api/packages/caw4tbrc9UwcSHudDj5PJv4-h5g= resulted in response with status code: [400, Bad Request]. Optional details: {"messageKey":"error.validation.sendPackage.noApprovals","message":"Cannot send package without approvals.","code":400,"name":"Validation Error"} Just wanted to know how do I fix this ? Any help is appreciated. - Shravan

harishaidary | Posts: 1812

Reply to: Creating the template or package give error

0 votes
Hey Shravan, As per the error message, you haven't added any signatures on your documents. In eSignLive, you cannot send a package without signatures on your documents. Looking at your package, it seems that you have successfully created a package from a template and replaced the placeholders but you only have the default-consent as document. The default-consent is automatically added when creating a package and is not enough to send a package. You will have to upload another document, add signatures on it and then you will be able to send your package.

shravanpolisetty | Posts: 5

Reply to: Creating the template or package give error

0 votes
Hey thanks so much, understood where I was going wrong. - Shravan

formpotato | Posts: 2

Reply to: Creating the template or package give error

0 votes
I created a sample template on https://sandbox.esignlive.com/a/template/PwqirCNvdF0YA3ibcofQq21pZH8= When I tried to send it out using .net EslClient eslClient; eslClient = new EslClient(apiKey, apiUrl); PackageId templateId = new PackageId(tID); var signer = SignerBuilder.NewSignerWithEmail("[email protected]") .WithFirstName("sample") .WithLastName("sample") .WithRoleId("Signer1") .Build(); DocumentPackage newPackage = PackageBuilder.NewPackageNamed("Test Template Package") .WithSigner(signer) .Build(); var packageId = eslClient.CreatePackageFromTemplate(templateId, newPackage); eslClient.SendPackage(packageId); Always return error: HTTP POST on URI https://sandbox.esignlive.com/api/packages/U_MTuWa_OjIJ4dOUSLzItV0JqwE=. Optional details: {"messageKey":"error.validation.packageActivation.unassignedRole","message":"There is a role with no signer.","code":400,"name":"Validation Error"}' BTW, could you elaborate what's the dfference with WithId(),WithRoleId(), WithCustomId()

Duo_Liang | Posts: 3776

Reply to: Creating the template or package give error

0 votes
Hi formpotato, If you are receiving a "There's a role without signer" error, it could probably because in original package, let's say you have two roles acting as a placeholder for template use. And when you want to create a new package from this template, you only assign one role or mismatched the Role ID so that OneSpan Sign could only detect one role matched. To explain the Role and Signer better, you can kindly check my latest blog. Then you will have a better understanding about the relationship between Role and Signature Approval. Hope this could help you!

Duo_Liang | Posts: 3776

Reply to: Creating the template or package give error

0 votes
Hi formpotato, And talking about the differences between WithId(),WithRoleId()and WithCustomId(), the attachment shows you a snippet of code and the corresponding JSON it represents (It may not necessary to be one to one mapping but it gives you the idea). In the attachment, you will see once you set with the WithCustomId(), the Role ID and Signer ID would be set to be the same and since you are using Template Feature, OneSpan Sign already know your document approvals and which signature approval you want to bind with the Role ID, that's why you would also see this Role ID under the "Approval" block in the JSON. Last two functions are straightforward, WithId() assigns the document ID and WithRoleId() only assigns the Role ID. Hope this could help you! Duo

Attachments
7-30-3.png55.37 KB

Hello! Looks like you're enjoying the discussion, but haven't signed up for an account.

When you create an account, we remember exactly what you've read, so you always come right back where you left off