SteveM

Java REST Setting the Sender is ignored

0 votes
I am tryng to change my working code from uploading a single PDF containing a "stage" of forms to upload each form selected from the "stage" as a PDF. Many of the stages select forms which do not contain signatures, so I am not getting any information for the sender and signers until later. I send a REST call to set the package sender and a role for it, but when I download the package it has the account owner as the sender. I am not getting any error or reponse when I PUT the sender. It is just ignoring me. Here is the jsonObject: // change the sender email on the package JsonObject jsonObject = Json.createObjectBuilder() .add("sender", Json.createObjectBuilder() .add("id", sender.getESignID()) .add("email", sender.getEMail())) .build(); Here is the REST I am sending: try { HttpURLConnection connection = (HttpURLConnection) new URL(serviceURL + "/packages/" + packageID).openConnection(); connection.setRequestMethod("PUT"); connection.setDoOutput(true); connection.setRequestProperty("Authorization", "Basic " + apiKey); connection.setRequestProperty("Accept", "application/json"); OutputStream output = connection.getOutputStream(); PrintWriter writer = new PrintWriter( new OutputStreamWriter(output, CHARSET), true); writer.append(CRLF).append(jsonObject.toString()).append(CRLF).flush(); LOGGER.info("E-Sign update package: " + packageID); int responseCode = connection.getResponseCode(); if (responseCode != HttpURLConnection.HTTP_OK) { throwConnectionError("E-Sign error updating package", connection); } } catch (IOException ex) { LOGGER.info(ex.getMessage()); throw new RuntimeException(ex.getMessage()); }

Attachments
junk.zip2.13 KB

Reply to: Java REST Setting the Sender is ignored

0 votes
Thanks Duo, I did just upload the zipped package for you. Before I was sending the Sender and it's role when I created the package after accumulating all of the forms in a PDF. Now I must send each form separately, so when I get to one that has signers, the package already contains the welcome or cover page form and maybe some others. I create the package as a draft and send the documents before finally changing it to SEND when the stage is completed. Our customers each have an API key and will create several senders for different purposes. I don't expect them to want the account owner as a sender for any of their packages. I use REST calls to add the senders and keep their ID's in a database so I can use them on the documents. I have logic which accepts the sender and other needed data for each signature. I guess it boils down to needing a way to upload documents for a new package without letting the account owner get defaulted so I can set the sender when it is available. Is there a way to do that?

Reply to: Java REST Setting the Sender is ignored

0 votes
Hi Steve, Sorry for the incorrect statement above. If you are creating package on behalf of another user under your main account, you can set sender's email in "sender" block as you did(guidance here). But it only works when creating the package, once you create the package (no matter the status is DRAFT or not), the transaction is in your hold so it's impossible to transfer it to another user. So what you can do here: 1. You simply accumulate the package information until you have the proper sender info to create the package. OR 2. You create a template with the initial info and when you have the sender info, you can clone the template into a transaction with the sender info, then, delete the template. Sorry again and hope my reply didn't confuse you. Duo

Duo Liang OneSpan Evangelism and Partner Integrations Developer


Reply to: Java REST Setting the Sender is ignored

0 votes
OK, I finally got back to this. I wound up writing a pre-process subroutine to go through the stage and find the first status and sender information. If the status is blank I POST with the sender I found. If I have a status I PUT using the package ID I found. I will keep the template idea just in case I get cornered again. Sounds like a way to improve performance in the future if uploading all the documents is too slow. Thanks for your help. BTW, and error response on the POST when the sender is changed would have saved a lot of time here.

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