Sample JSON request Body to Create Package with Document Content as Byte Stream
Wednesday, October 19, 2016 at 03:13amHi,
Can you provide a sample JSON request Body to Create Package with Document Content as a PDF Byte Stream.
Thanks
OneSpan Introduces DigipassONE, Bringing a Unified Platform Approach to Authentication Modernization
A new authentication platform helps financial institutions support diverse customer authentication preferences while modernizing at their own pace Learn More
Reply to: Sample JSON request Body to Create Package with Document Content as Byte Stream
Wednesday, October 19, 2016 at 03:39amReply to: Sample JSON request Body to Create Package with Document Content as Byte Stream
Wednesday, October 19, 2016 at 03:57amReply to: Sample JSON request Body to Create Package with Document Content as Byte Stream
Wednesday, October 19, 2016 at 04:00amReply to: Sample JSON request Body to Create Package with Document Content as Byte Stream
Tuesday, October 25, 2016 at 12:27pmReply to: Sample JSON request Body to Create Package with Document Content as Byte Stream
Wednesday, October 26, 2016 at 05:50ampackage example.codes; import java.io.BufferedReader; import java.io.File; import java.io.IOException; import java.io.InputStreamReader; import java.io.OutputStream; import java.io.OutputStreamWriter; import java.io.PrintWriter; import java.net.HttpURLConnection; import java.net.MalformedURLException; import java.net.URL; import java.net.URLConnection; import java.nio.file.Files; import javax.net.ssl.HttpsURLConnection; public class CreateAndSendPackageRest { public static void main(String[] args) throws MalformedURLException, IOException { HttpsURLConnection connection = null; String requestURL = "https://sandbox.esignlive.com/api/packages"; String apiKey = "api_key"; String charset = "UTF-8"; File uploadFile1 = new File("C:/Users/hhaidary/Desktop/PDFs/doc1.pdf"); String boundary = Long.toHexString(System.currentTimeMillis()); String CRLF = "\r\n"; // Line separator used in multipart/form-data. String jsonContent = "{\"roles\":[{\"locked\":false,\"emailMessage\":{\"content\":\"\"},\"attachmentRequirements\":[],\"reassign\":false,\"specialTypes\":[],\"id\":\"Sender\",\"data\":null,\"type\":\"SIGNER\",\"index\":0,\"signers\":[{\"auth\":{\"challenges\":[],\"scheme\":\"NONE\"},\"company\":\"Silanis\",\"firstName\":\"yourFirst\",\"lastName\":\"yourLast\",\"phone\":\"\",\"email\":\"[email protected]\",\"knowledgeBasedAuthentication\":null,\"language\":\"en\",\"title\":\"Silanis\",\"external\":null,\"professionalIdentityFields\":[],\"userCustomFields\":[],\"delivery\":{\"email\":true,\"provider\":false,\"download\":true},\"group\":null,\"signature\":null,\"address\":null,\"data\":null,\"name\":\"\",\"specialTypes\":[]}],\"name\":\"Sender\"},{\"locked\":false,\"emailMessage\":{\"content\":\"\"},\"attachmentRequirements\":[],\"reassign\":false,\"specialTypes\":[],\"id\":\"Signer\",\"data\":null,\"type\":\"SIGNER\",\"index\":0,\"signers\":[{\"auth\":{\"challenges\":[],\"scheme\":\"NONE\"},\"company\":\"\",\"firstName\":\"signerFirst\",\"lastName\":\"signerLast\",\"phone\":\"\",\"email\":\"[email protected]\",\"knowledgeBasedAuthentication\":null,\"language\":\"en\",\"title\":\"\",\"external\":null,\"professionalIdentityFields\":[],\"userCustomFields\":[],\"delivery\":{\"email\":false,\"provider\":false,\"download\":false},\"group\":null,\"id\":\"Signer\",\"signature\":null,\"address\":null,\"data\":null,\"name\":\"\",\"specialTypes\":[]}],\"name\":\"Signer\"}],\"documents\": [{\"approvals\":[{\"role\":\"Signer\",\"signed\":null,\"accepted\":null,\"data\":null,\"fields\":[{\"page\":0,\"subtype\":\"FULLNAME\",\"width\":200,\"binding\":null,\"extract\":false,\"extractAnchor\":null,\"left\":175,\"top\":165,\"validation\":null,\"height\":50,\"data\":null,\"type\":\"SIGNATURE\",\"value\":\"\"}],\"name\":\"\"},{\"role\":\"Sender\",\"signed\":null,\"accepted\":null,\"data\":null,\"fields\":[{\"page\":0,\"subtype\":\"FULLNAME\",\"width\":200,\"binding\":null,\"extract\":false,\"extractAnchor\":null,\"left\":550,\"top\":165,\"validation\":null,\"height\":50,\"data\":null,\"type\":\"SIGNATURE\",\"value\":\"\"}],\"name\":\"\"}],\"name\": \"sampleAgreement\"}],\"name\": \"Test Package REST\", \"type\":\"PACKAGE\", \"language\":\"en\", \"emailMessage\":\"\", \"description\":\"New Package\",\"autoComplete\":true,\"status\":\"SENT\"}"; URL url = new URL(requestURL); connection = (HttpsURLConnection) url.openConnection(); connection.setDoOutput(true); connection.setDoInput(true); connection.setRequestMethod("POST"); connection.setRequestProperty("Content-Type", "multipart/form-data; boundary=" + boundary); connection.setRequestProperty("Authorization", "Basic " + apiKey); connection.setRequestProperty("Accept", "application/json; esl-api-version=11.0"); OutputStream output = connection.getOutputStream(); PrintWriter writer = new PrintWriter(new OutputStreamWriter(output, charset), true); try { // Add pdf file. writer.append("--" + boundary).append(CRLF); writer.append("Content-Disposition: form-data; name=\"file\"; filename=\"" + uploadFile1.getName() + "\"") .append(CRLF); writer.append("Content-Type: " + URLConnection.guessContentTypeFromName(uploadFile1.getName())) .append(CRLF); writer.append("Content-Transfer-Encoding: application/pdf").append(CRLF); writer.append(CRLF).flush(); Files.copy(uploadFile1.toPath(), output); output.flush(); writer.append(CRLF).flush(); // add json payload writer.append("--" + boundary).append(CRLF); writer.append("Content-Disposition: form-data; name=\"payload\"").append(CRLF); writer.append("Content-Type: application/json; charset=" + charset).append(CRLF); writer.append(CRLF).append(jsonContent).append(CRLF).flush(); // End of multipart/form-data. writer.append("--" + boundary + "--").append(CRLF).flush(); } catch (IOException ex) { System.err.println(ex); } // get and write out response code int responseCode = ((HttpURLConnection) connection).getResponseCode(); System.out.println(responseCode); if (responseCode == 200) { // get and write out response BufferedReader in = new BufferedReader(new InputStreamReader(connection.getInputStream())); String inputLine; StringBuffer response = new StringBuffer(); while ((inputLine = in.readLine()) != null) { response.append(inputLine); } in.close(); // print result System.out.println(response.toString()); } else { // get and write out response BufferedReader in = new BufferedReader(new InputStreamReader(connection.getErrorStream())); String inputLine; StringBuffer response = new StringBuffer(); while ((inputLine = in.readLine()) != null) { response.append(inputLine); } in.close(); // print result System.out.println(response.toString()); } } }Don't forget to replace the api_key placeholder with your own value.Reply to: Sample JSON request Body to Create Package with Document Content as Byte Stream
Wednesday, October 26, 2016 at 09:39amReply to: Sample JSON request Body to Create Package with Document Content as Byte Stream
Thursday, October 27, 2016 at 04:29amReply to: Sample JSON request Body to Create Package with Document Content as Byte Stream
Thursday, October 27, 2016 at 04:49amReply to: Sample JSON request Body to Create Package with Document Content as Byte Stream
Thursday, October 27, 2016 at 04:59amReply to: Sample JSON request Body to Create Package with Document Content as Byte Stream
Tuesday, November 1, 2016 at 06:16amReply to: Sample JSON request Body to Create Package with Document Content as Byte Stream
Tuesday, November 1, 2016 at 07:48am{ "roles": [ { "locked": false, "emailMessage": { "content": "" }, "attachmentRequirements": [], "reassign": false, "specialTypes": [], "id": "Signer", "data": null, "type": "SIGNER", "index": 0, "signers": [ { "auth": { "challenges": [], "scheme": "NONE" }, "company": "Assurant", "firstName": "Pammy", "lastName": "Singh", "phone": "", "email": "[email protected]", "knowledgeBasedAuthentication": null, "language": "en", "title": "Assurant", "external": null, "professionalIdentityFields": [], "userCustomFields": [], "delivery": { "email": true, "provider": false, "download": true }, "group": null, "signature": null, "address": null, "data": null, "name": "", "specialTypes": [] } ], "name": "Signer" }, { "locked": false, "emailMessage": { "content": "" }, "attachmentRequirements": [], "reassign": false, "specialTypes": [], "id": "Sender", "data": null, "type": "SENDER", "index": 0, "signers": [ { "auth": { "challenges": [], "scheme": "NONE" }, "company": "Assurant", "firstName": "Permender", "lastName": "Matharu", "phone": "", "email": "[email protected]", "knowledgeBasedAuthentication": null, "language": "en", "title": "", "external": null, "professionalIdentityFields": [], "userCustomFields": [], "delivery": { "email": false, "provider": false, "download": false }, "group": null, "id": "Sender", "signature": null, "address": null, "data": null, "name": "", "specialTypes": [] } ], "name": "Sender" } ], "documents": [ { "extract": true, "name": "signTags" } ], "name": "Test Package REST", "type": "PACKAGE", "language": "en", "emailMessage": "", "description": "New Package", "autoComplete": true, "status": "SENT" }Next, [Signer.SomeName] is not a valid form field name. They should be something like [Signer.Capture1] where Capture1 is the signature style (this can't be some random name). More information about document extraction is available here: http://docs.esignlive.com/content/c_integrator_s_guide/sdk/c_managing_documents/extraction.htm