sudhangi | Posts: 59

Could not update role Exception

0 votes
Hi, When I try to updatePackage() I get the following exception. I am trying to update the package with additional signer information to a placeholder block in the document when I get this problem. Any idea why would this happen? com.silanis.esl.sdk.internal.EslServerException: Could not update role Exception: HTTP PUT on URI https://sandbox.e-signlive.com/api/packages/fb433c2d-8fa3-47db-97d9-81e92ff5780d/roles/FormB_RequestingProgramOfficial resulted in response with status code: [500, Internal Server Error]. Optional details: {"messageKey":"error.internal.default","packageId":null,"entity":null,"technical":null,"message":"Unexpected error. We apologize for any inconvenience this may have caused you, please try again. If the problem persists, please contact our support team.","code":500,"name":"Unhandled Server Error"} com.silanis.esl.sdk.internal.EslServerException: Could not update role Exception: HTTP PUT on URI https://sandbox.e-signlive.com/api/packages/fb433c2d-8fa3-47db-97d9-81e92ff5780d/roles/FormB_RequestingProgramOfficial resulted in response with status code: [500, Internal Server Error]. Optional details: {"messageKey":"error.internal.default","packageId":null,"entity":null,"technical":null,"message":"Unexpected error. We apologize for any inconvenience this may have caused you, please try again. If the problem persists, please contact our support team.","code":500,"name":"Unhandled Server Error"} at com.silanis.esl.sdk.service.PackageService.updateRole(PackageService.java:501) at com.silanis.esl.sdk.service.PackageService.updatePackage(PackageService.java:170) at com.silanis.esl.sdk.EslClient.updatePackage(EslClient.java:253) Thanks, Sudhangi

Approved Answer
mwilliams | Posts: 957

Reply to: Could not update role Exception

0 votes
Take a look at this code:
DocumentId docId = createdPackage.getDocument("sampleAgreement").getId(); //grab document
        eslClient.getLayoutService().applyLayout(myPackage, docId.getId(), docLayoutId.getId()); //apply layout (3 placeholders) My document contains signatures for 3 different signers. The third being a dummy email so I can repurpose that signature from the layout to be for signer1.
        
        createdPackage = eslClient.getPackage(myPackage); //get updated package after applying layout
        Collection mysigs = createdPackage.getDocument("sampleAgreement").getSignatures(); //get all signatures
        List sigsToMove = new ArrayList(); //create a new List to store all signatures in for "update".
        Signature mynewsig = null; //create signature object to use to create new signatures to transfer from signer3 to signer1.
        for(Signature sig : mysigs){ //walk through signatures
        	String email = sig.getSignerEmail();
        	if (email.equals("[email protected]")){ //check signature email against known dummy email
        		Collection myfields = sig.getFields(); //grab fields from signature
        		mynewsig = SignatureBuilder.signatureFor("[email protected]") //create new signature for signer1 and transfer all value from
        				.atPosition(sig.getX(), sig.getY())
        				.withSize(sig.getWidth(), sig.getHeight())
        				.withId(sig.getId())
        				.onPage(sig.getPage())
        				.build();
        		mynewsig.addFields(myfields); //add all fields from old signature to new signature
        		sigsToMove.add(mynewsig); //add new signature to signature list
        	}
        	else{
        		sigsToMove.add(sig);//add unchanged signature to signature list
        	}
        }
       	eslClient.getPackageService().removeSigner(myPackage, createdPackage.getSigner("[email protected]").getId()); //remove the temp signer
        createdPackage = eslClient.getPackage(myPackage); //get updated package
        eslClient.getApprovalService().updateSignatures(createdPackage, docId.getId(), sigsToMove); //update all signatures for document
You would just have to do this for each document that you apply a layout to. Hope this helps. Let me know if you have issues.

mwilliams | Posts: 957

Reply to: Could not update role Exception

0 votes
Is this a package or a template that you're trying to edit? The reason I ask is you say you're trying to update the placeholder, which would be an empty signer in a template used to reserve the signer slot for the actual signer so you can place signatures and fields on documents that will be inherited by the eventual signer. If you're meaning you're trying to update a signer in a package, is the package in DRAFT mode when you're trying to do the update? Has the signer signed anything already at the time of update? Please let me know!

sudhangi | Posts: 59

Reply to: Could not update role Exception

0 votes
Hi Micheal, Thank you for your response. This is actually a case where I have to do the following: 1. Build a package say 'PackageOne' 2. Add 2 documents to this PackageOne 3. Add multiple signers to each of these documents 4. Apply 2 different layouts to the 2 documents. Which will have different placeholder names for the signing blocks. 5. Based on a business logic I need to assign signers to each placeholder 6. Among the signers, one signer will need to sign 2 documents. 7. During the above 6 steps, PacakageOne will be in draft mode. I hope this helps clarify what I am trying to do. Thanks, Sudhangi

mwilliams | Posts: 957

Reply to: Could not update role Exception

0 votes
Hey Sudhangi, Thanks for the info. What I'm still not certain on is if you're building a package from scratch or using a template.

sudhangi | Posts: 59

Reply to: Could not update role Exception

0 votes
Hey Michael, I am building a package from scratch. Thanks, Sudhangi

mwilliams | Posts: 957

Reply to: Could not update role Exception

0 votes
Okay. Thank you. Are you against building all of this at one time? Or do you need to add all of these things separately? A good guide to look at for doing all of this at one time is this one: Quick Start Guide - Create and Send a Package with Java SDK If you're wanting to do this in multiple steps like you listed above, you can do that, too. You can build a document package like in the guide above only leaving out the document and signer portions. Then, add documents as in this guide: Document Management Guide Then, you add signers to the package: Signer Management Guide Then, add signatures to the documents: Signatures Guide These signatures can also be added more dynamically at document upload time with Document Extraction or Text Anchors. The easiest way to do this would be the Quick Start Guide where you just define it all at one time. So, to recap, to create a package from scratch, you don't use Placeholders. You create a document package, add your signers (anyone that will sign anywhere in any of your documents), you add the documents, and finally, define the signatures and fields that the signers you've already defined need to fill out. Hopefully this makes things more clear on how you should set up your document packages. Let me know.

sudhangi | Posts: 59

Reply to: Could not update role Exception

0 votes
Hi Michael, Thank you for your response. Let me try and simplify this for you. Below is a simple program very similar to what I am trying to do: int itr = 0; PackageId docLayoutId =null; Placeholder p1 =null; Placeholder p0 =null; List layouts = eslClient.getLayoutService().getLayouts(Direction.DESCENDING, new PageRequest(itr, 50)); for (DocumentPackage myLayout : layouts) { if (myLayout.getName().equals("SampleShare3") ) { docLayoutId = myLayout.getId(); p0 = new Placeholder( "Signer1"); p1 = new Placeholder( "Signer2"); break; } } PackageBuilder package1 = PackageBuilder.newPackageNamed("Layout"); package1.withSenderInfo(SenderInfoBuilder.newSenderInfo("[email protected]")); signer = SignerBuilder.newSignerWithEmail("[email protected]") .withFirstName("Sudhangi") .withLastName("ICFI").replacing(p1); package1.withSigner(signer); signer=SignerBuilder.newSignerWithEmail("[email protected]") .withFirstName("Dss") .withLastName("Dev").replacing(p0); package1.withSigner(signer); Document mydoc = DocumentBuilder.newDocumentWithName("TEST-AAAP-Short") .fromFile("/Users/SAmbekar/Desktop/Development/GSA/AAAP/TEST-AAAP-Short.PDF") .build(); package1.withDocument(mydoc); DocumentPackage completePackage = package1 .withAttributes(DocumentPackageAttributesBuilder.newDocumentPackageAttributes() .withAttribute("orgName", "IACP") .build()) .build(); PackageId packageId = eslClient.createPackage(completePackage); List packageDocuments= eslClient.getPackage(packageId).getDocuments(); for (int k = 1; k packageDocuments.size(); k++) { String docId = packageDocuments.get(k).getId().toString(); eslClient.getLayoutService().applyLayout(packageId, docId, docLayoutId.toString()); } /*There are a total of 4 placeholders, Signer1, Signer2, Signer3 and Signer4. */ for(Signer s: eslClient.getPackage(packageId).getPlaceholders()) { System.out.println("PlaceHolderName+\t"+s.getPlaceholderName()); if (s.getPlaceholderName() == "Signer3") { /*Add the signer [email protected] to this placeholder 'Signer3'*/ /*How do I update the package at this point?*/ } else { /*Remove the placeholder Signer4 */ eslClient.getPackageService().removeSigner(packageId, s.getId()); } } System.out.println("PackageID+\t"+packageId.toString()); } } If you look in the code, I am trying to use a previous signer as assign that to another placeholder Signer3, how do I update the package at this point? Thanks, Sudhangi

Attachments
mwilliams | Posts: 957

Reply to: Could not update role Exception

0 votes
Okay. I'm with you, now. You won't be able to assign the same email address to signer3 as is for signer1. What you'll probably have to do to handle your issue is to pass a dummy signer for signer3, then, walk through the document package and reassign all signatures and fields for signer3 and give them to signer1. Finally, remove signer 3 and placeholder 4. I have not tested this, yet, but I will right now and let you know the result.

sudhangi | Posts: 59

Reply to: Could not update role Exception

0 votes
Hi Michael, Appreciate your detailed response. Let me try this out. I will get back to you. Thanks, Sudhangi

mwilliams | Posts: 957

Reply to: Could not update role Exception

0 votes
Not a problem at all. Definitely let me know if you have any issues with it.

sudhangi | Posts: 59

Reply to: Could not update role Exception

0 votes
Hi Michael, Your solution of using dummy email worked. I am going to try this on the actual requirement, which involves multiple documents, multiple layouts and multiple placeholders. I will keep you posted once I get that working. Thank you very much, Sudhangi

mwilliams | Posts: 957

Reply to: Could not update role Exception

0 votes
Great to hear! Let me know how it goes. If it's very difficult to get everything working properly, you could always just avoid the templates and create the package completely from scratch each time depending on the number of signers, since you're integrated. Layouts and templates are generally utilized most by UI users to avoid having to manually upload documents/place fields. :)

sudhangi | Posts: 59

Reply to: Could not update role Exception

0 votes
Thank you very much Michael. That solution worked for me. Regards, Sudhangi

mwilliams | Posts: 957

Reply to: Could not update role Exception

0 votes
Great! Thanks for the update! :)

sudhangi | Posts: 59

Reply to: Could not update role Exception

0 votes
Hi Michael, I have come across the same problem once again while using updatePackage(). I get the error "Could not update role Exception" But his time my use case is very simple. I have a package in the draft status without any documents or signers in it, so essentially it is a Empty Package I use the Java SDK and add a document and signer to a DocumentPackage and try to update the existing empty package with it , but end up with the same exception. I used the sample code from: https://github.com/OneSpan/esl.sdk.java/blob/master/sdk/src/main/java/com/silanis/esl/sdk/examples/UpdatePackageExample.java But instead of updating the setting I am updating the document and signer. Any idea why that would be the case.

Duo_Liang | Posts: 3776

Reply to: Could not update role Exception

0 votes
Hi sudhangi, If you want to update/add signers and documents to an existing package, updatePackage() function won't work. This function only updates package level attributes (settings/descriptions/emailMessage/expireData/etc.) like the sample code does:
 packageToUpdate = PackageBuilder.newPackageNamed(NEW_PACKAGE_NAME)
                .describedAs(NEW_DESCRIPTION)
                .withEmailMessage(NEW_EMAIL_MESSAGE)
                .expiresAt(now().plusMonths(2).toDate())
                .withLanguage(Locale.FRENCH)
                .withVisibility(NEW_VISIBILITY)
                .withNotarized(NEW_NOTARIZED)
                .autocomplete(false)
                .withSettings(settingsToUpdate)
                .build();
Instead, you'd use following two functions to add signers and documents separately:
eslClient.uploadDocuments(PackageId packageId, List documents);
		eslClient.getPackageService().addSigner(PackageId packageId, com.silanis.esl.sdk.Signer signer);
Among them, documents can be bulk uploaded while signers/roles have to be added one by one. And BTW, may I know the SDK version you are currently using? Hope this could help! Duo

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