ctewell

Apex call to getPackage() method not working

0 votes
I am using a sandbox so perhaps the class definition does not match what is there. I get an invalid primitive error on the following code snippet: string pkgId = ESignLiveExamples.createPackageExample(); ESignLiveSDK sdk = new ESignLiveSDK(); ESignLiveAPIObjects.Package_x pkg = sdk.getPackage(pkgId); Here is the error on my page: Error getting the Package: Illegal value for primitive Error is in expression '{!TestESL}' in component in page espackage: Class.ESignLiveRESTAPIHelper.getPackage: line 772, column 1 Class.ESignLiveSDK.getPackage: line 210, column 1 Class.ESPackageController.TestESL: line 96, column 1 Line 772 is the throw statement below. So the JSON.deserialize is failing. try { pkg = (ESignLiveAPIObjects.Package_x)JSON.deserialize(inboundResponseBody, ESignLiveAPIObjects.Package_x.class); } catch(Exception e) { throw new ESignLiveRestAPIHelperException('Error getting the Package: ' + e.getMessage()); } Digging a little more the Package_x.document.data field is defined in the class as a string. The return value is a class.

Reply to: Apex call to getPackage() method not working

0 votes
Hey ctewell, I will take a look at the code here shortly. Is the "createPackageExample()" call from the github page? Or is this something you created?

- Michael

Director, Partner and Developer Technologies, OneSpan

Facebook - Twitter - LinkedIn


Reply to: Apex call to getPackage() method not working

0 votes
Yes, Micheal ESignLiveExamples.createPackageExample() is from the gitHub page.

Reply to: Apex call to getPackage() method not working

0 votes
From the createPackageExample() function, are you getting the package ID created?
System.debug('=> Response from createPackageExample: ' + packageId);
In your code, if you put a line to print this out to the console after calling the function, are you getting a valid "pkgId" value? string pkgId = ESignLiveExamples.createPackageExample();

- Michael

Director, Partner and Developer Technologies, OneSpan

Facebook - Twitter - LinkedIn


Reply to: Apex call to getPackage() method not working

0 votes
Yes, I am getting a packageId back. See debug below. In addition, I can see the package was created in my eSignLive sandbox. 13:46:48.20 (2020800674)|SYSTEM_METHOD_EXIT|[30]|System.debug(ANY) 13:46:48.20 (2020808647)|SYSTEM_MODE_EXIT|false 13:46:48.20 (2020830442)|SYSTEM_METHOD_ENTRY|[3]|System.debug(ANY) 13:46:48.20 (2020835832)|USER_DEBUG|[3]|DEBUG|Package Id returned from createPackageExample() is sgN6uTTQwqsgo5hbf5t3yPqFi_E= 13:46:48.20 (2020838465)|SYSTEM_METHOD_EXIT|[3]|System.debug(ANY) 13:46:48.20 (2020878763)|SYSTEM_MODE_ENTER|false

Reply to: Apex call to getPackage() method not working

0 votes
Can you try creating a transaction in your sandbox account UI, including adding documents and fields to it and try using the resulting transaction ID (from the URL) statically in your code? Maybe there is a bug on a get request if there are not documents/approvals/fields. If you can successfully pull a complete package, we might figure out that there is an issue with the SDK parsing the payload of a package that doesn't have every part necessary for a package to be sent.

- Michael

Director, Partner and Developer Technologies, OneSpan

Facebook - Twitter - LinkedIn


Reply to: Apex call to getPackage() method not working

0 votes
This still produced the Illegal Value for primitive error. Here is my apex code: string pkgId = 'XNK3bbE32PmfGYwlVMk1nGJoyN8='; System.debug('Package Id beomg used is ' + pkgId); ESignLiveSDK sdk = new ESignLiveSDK(); ESignLiveAPIObjects.Package_x pkg = sdk.getPackage(pkgId); Here is the error message. 14:54:26.64 (302927520)|EXCEPTION_THROWN|[6]|ESignLiveRESTAPIHelper.ESignLiveRestAPIHelperException: Error getting the Package: Illegal value for primitive Screenshot of eSignLive transaction is attached. Out of curiousity, what happens when you execute a getPackage() from your Salesforce environment?

Attachments

Reply to: Apex call to getPackage() method not working

0 votes
I don't actually have a way to test this internally, at this moment. I will check to see if I can get a way to test. When you set up your transaction, did you set up a signature on the document for the sender?

- Michael

Director, Partner and Developer Technologies, OneSpan

Facebook - Twitter - LinkedIn


Reply to: Apex call to getPackage() method not working

0 votes
I did not set up a signature for the Sender. Do I have to add myself as a signer to do that? Otherwise, please tell me how if you think that would help.

Reply to: Apex call to getPackage() method not working

0 votes
Sorry. I meant for the signer. I saw you had a signer on the transaction, but did you set up a signature on the document. I just wanted to make sure the package JSON had all the necessary items in it to be sure it wasn't an issue around that. As of right now, it's looking like a bug in the SDK, though, it seems odd that this hasn't been uncovered before as I don't know that there has been an update to this in a while. I will keep investigating this on my side to see if I can get an environment to actually test it out. If not, I'll reach out to Kadence (the folks that created this SDK) to see if they have any ideas as to why there is an issue with the JSON.

- Michael

Director, Partner and Developer Technologies, OneSpan

Facebook - Twitter - LinkedIn


Reply to: Apex call to getPackage() method not working

0 votes
You can get a free Salesforce environment here if interested. https://developer.salesforce.com/signup?d=70130000000td6N So, how is the eSignLIve Apex SDK supported? Is it supported by Kadence and not eSignLive? Yes, I went into the designer and put the signature on the document. Thanks for your help on this.

Reply to: Apex call to getPackage() method not working

0 votes
I was able to fix this. I modified ESignLIveApiObjects.cls. The Document.data variable is returning as a class, not a string. "data":{ "ese_document_texttag_extract_needed":"false" }, So I modified the Document definition as follows: public class Document { public List approvals; // ctewell change variable name because it is coming back as a class. public String dataZ; .... .... then in the constructor: public Document(List approvals, String data, String description, External external, List fields, String id, Integer index, String name, List pages, Integer size) { this.approvals = approvals; this.dataZ = data; ... ... dataZ gets ignored. I could have defined data as an inner class but don't care about the attribute.

Reply to: Apex call to getPackage() method not working

0 votes
Thanks for posting your update! BTW, Kadence built the SDK and has been helping with support through our developer site as well, as we don't have much Salesforce dev knowledge in our tech evangelism staff, at this time. I just gained access to a Salesforce environment, so hopefully that will change. ;) Thanks again for posting your fix!

- Michael

Director, Partner and Developer Technologies, OneSpan

Facebook - Twitter - LinkedIn


Reply to: Apex call to getPackage() method not working

0 votes
Thank you, we've been experiencing this as well

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