Create the package only with documents and update the package adding the signers later.
Tuesday, October 20, 2020 at 11:37amI am trying to create the package only with documents and I will need to update it later adding the signers, the signature tag is already created in one of the documents, that is why I am using EnableExtraction. I get an error:
Could not send the package. Exception: The remote server returned an error: (400) Bad Request. HTTP POST on URI https://sandbox.esignlive.com/api/packages/*********. Optional details: {"messageKey":"error.validation.sendPackage.noApprovals","message":"Cannot send package without approvals.","code":400,"name":"Validation Error"}
Code for the document creation:
var client = new OssClient(apiKey, apiUrl);
var stream = new MemoryStream(document);
var packageName = Guid.NewGuid().ToString("n").Substring(0, 8);
DocumentPackage package = PackageBuilder.NewPackageNamed(packageName)
.WithDocument(DocumentBuilder.NewDocumentNamed(documentId)
.FromStream(stream, DocumentType.PDF)
.EnableExtraction()
)
.Build();
var packageId = client.CreatePackage(package);
Code for adding the signers:
var client = new OssClient(apiKey, apiUrl);
var packageId = new PackageId(packageString);
var package = client.GetPackage(packageId);
var existingSigners = package.Signers;
var signatureParticipantFieldName = $"Sig_es_:signer1:signature";
var email = "email@email.com";
var firstName = "FirstName";
var lastName = "LastName";
if (!existingSigners.Any(x => x.Email == email))
{
Signer signer = SignerBuilder.NewSignerWithEmail(email)
.WithFirstName(firstName)
.WithLastName(lastName)
.Build();
package.Signers.Add(signer);
}
var signature = SignatureBuilder.CaptureFor(email)
.WithName(signatureParticipantFieldName)
.WithPositionExtracted()
.Build();
foreach (var document in package.Documents)
{
document.Signatures.Add(signature);
}
client.UpdatePackage(packageId, package);
client.SendPackage(packageId);
Reply to: Create the package only with documents and update the package adding the signers later.
Tuesday, October 20, 2020 at 01:37pmI was testing it with one of your examples but I get another error: OneSpanSign.Sdk.OssException: 'No Role found for signer email someemail@gmail.com'
var client = new OssClient(apiKey, apiUrl);
var packageId = new PackageId(packageString);
//Add a signature
var signature = SignatureBuilder.SignatureFor("someemail@gmail.com")
.OnPage(0)
.AtPosition(215, 510)
.WithSize(200, 50)
.WithId(new SignatureId("signature1"))
.Build();
var createdPackage = client.GetPackage(packageId);
var documentId = createdPackage.GetDocument("SignAndInitials_Example").Id;
// Error here: OneSpanSign.Sdk.OssException: 'No Role found for signer email someemail@gmail.com'
client.ApprovalService.AddApproval(createdPackage, documentId, signature);
//Update a signature
var updatedSignature = SignatureBuilder.CaptureFor("someemail@gmail.com")
.OnPage(0)
.AtPosition(215, 510)
.WithSize(300, 50)
.WithId(new SignatureId("signature1"))
.Build();
var signatures = new List<Signature>();
signatures.Add(updatedSignature);
var updatedPackage = client.GetPackage(packageId);
client.ApprovalService.UpdateApprovals(updatedPackage, documentId, signatures);
//Delete a signature
client.ApprovalService.DeleteApproval(packageId, documentId, "signature1");
Reply to: Create the package only with documents and update the package adding the signers later.
Tuesday, October 20, 2020 at 01:44pmHi Jose,
Code wise, these places caused the issue:
(1)"client.UpdatePackage(packageId, package);" this call only updates package level attributes, for example due date, package description, but won't update signers and signature fields
(2)I see you are trying to leverage the position extraction feature, however OneSpan Sign document engine will only detect the PDF forms during its first upload - subsequent calls won't trigger the mapping.
If you can't determine the signer information, or even the signer numbers, you can add Placeholder recipients first then later update the placeholder with real signer information or remove the placeholder (fields binded to the placeholder will also be automatically deleted)
Use the sample code and PDF in Position Extraction guide for example:
OssClient ossClient = new OssClient(API_KEY, API_URL);
Placeholder placeholder = new Placeholder("Placeholder1");
DocumentPackage superDuperPackage = PackageBuilder.NewPackageNamed("Sample Insurance policy")
.WithSigner(SignerBuilder.NewSignerPlaceholder(placeholder))
.WithDocument(DocumentBuilder.NewDocumentNamed("First Document")
.FromFile("your_file_path")
.EnableExtraction()
.WithSignature(SignatureBuilder.SignatureFor(placeholder)
.WithName("sig1")
.WithPositionExtracted()
))
.Build();
PackageId packageId = ossClient.CreatePackage(superDuperPackage);
Debug.WriteLine($"package id: {packageId.Id}");
Signer signer = SignerBuilder.NewSignerWithEmail("signer@example.com")
.WithFirstName("John")
.WithLastName("Smith")
.WithCustomId(placeholder.Id)
.Build();
ossClient.PackageService.UpdateSigner(packageId, signer);
//ossClient.PackageService.RemoveSigner(packageId, placeholder.Id); //to remove optional placeholders
ossClient.SendPackage(packageId);
Duo