Sample code to send pdf file via rest api
Thursday, June 27, 2019 at 02:27amHello, I want to send a pdf file using e-sign.
I sent a file (by creating transaction) using sandbox account manually and I want to do the same via rest api.
But I am not able to figure out the json content for the sender and signer details in plsql.
Reply to: Sample code to send pdf file via rest api
Thursday, June 27, 2019 at 05:30amHi there, Yes, you can directly use above dummy payload. You can also refer to this thread "Trouble uploading a document through multipart/form-data via Oracle's UTL_HTTP" for reference. Duo
Reply to: Sample code to send pdf file via rest api
Thursday, June 27, 2019 at 03:03am{ "roles":[ { "id":"Role1", "signers":[ { "email":"[email protected]", "firstName":"1.firstname", "lastName":"1.lastname", "company":"OneSpan Sign" } ] }, { "id":"Role2", "signers":[ { "email":"[email protected]", "firstName":"2.firstname", "lastName":"2.lastname", "company":"OneSpan Sign" } ] } ], "documents":[ { "approvals":[ { "role":"Role1", "fields":[ { "page":0, "top":100, "subtype":"FULLNAME", "height":50, "left":100, "width":200, "type":"SIGNATURE" } ] }, { "role":"Role2", "fields":[ { "page":0, "top":300, "subtype":"FULLNAME", "height":50, "left":100, "width":200, "type":"SIGNATURE" } ] } ], "name":"Test Document" } ], "name":"Example Package", "type":"PACKAGE", "language":"en", "emailMessage":"", "description":"New Package", "autocomplete":true, "status":"SENT" }At the bottom of Creating and Sending a Package guide, we also have a JSON Properties table tells you all optional attributes for payload. Tell me what else I can help! :) DuoReply to: Sample code to send pdf file via rest api
Thursday, June 27, 2019 at 03:21amReply to: Sample code to send pdf file via rest api
Thursday, July 18, 2019 at 09:31pm302 Found
Reply to: Sample code to send pdf file via rest api
Friday, July 19, 2019 at 04:52amReply to: Sample code to send pdf file via rest api
Sunday, July 21, 2019 at 09:38pmReply to: Sample code to send pdf file via rest api
Monday, July 22, 2019 at 01:27amReply to: Sample code to send pdf file via rest api
Monday, July 22, 2019 at 01:56amReply to: Sample code to send pdf file via rest api
Monday, July 22, 2019 at 04:30amReply to: Sample code to send pdf file via rest api
Tuesday, July 23, 2019 at 02:34amReply to: Sample code to send pdf file via rest api
Tuesday, July 23, 2019 at 06:12amReply to: Sample code to send pdf file via rest api
Friday, July 26, 2019 at 01:37amReply to: Sample code to send pdf file via rest api
Friday, July 26, 2019 at 09:26amset serveroutput on; create or replace procedure create_package2 as oss_api_url constant varchar2(256) := 'https://sandbox.esignlive.com/api'; oss_api_key constant varchar2(256) := 'your_api_key'; l_newline varchar2(50) := chr(13) || chr(10); lco_boundary constant varchar2(30) := 'gc0p4Jq0M2Yt08jU534c0p'; l_http_request utl_http.req; l_request_body clob; l_request_body_length number; l_http_response utl_http.resp; l_response_header_name varchar2(256); l_response_header_value varchar2(1024); l_response_body varchar2(32767); l_offset number := 1; l_amount number := 2000; l_buffer varchar2(2000); v_blob blob; v_buffer raw(32767); v_file bfile := bfilename('MYDIR', 'SampleDoc.pdf'); v_length integer; v_offset number(15) := 1; v_amount number(15) := 32767; begin l_http_request := utl_http.begin_request( url => oss_api_url || '/packages', method => 'POST', http_version => 'HTTP/1.1' ); utl_http.set_wallet('file:C:\wallet5', NULL); utl_http.set_header(l_http_request, 'Authorization', 'Basic ' || oss_api_key); utl_http.set_header(l_http_request, 'Content-Type', 'multipart/form-data; boundary="' || lco_boundary || '"'); utl_http.set_header(l_http_request, 'Transfer-Encoding', 'chunked'); l_request_body := l_newline || '--' || lco_boundary || l_newline || 'Content-Disposition: form-data; name="file"; filename="file.pdf"' || l_newline || 'Content-Type: application/pdf' || l_newline || l_newline; l_request_body_length := dbms_lob.getlength(l_request_body); while l_offset l_request_body_length loop dbms_lob.read(l_request_body, l_amount, l_offset, l_buffer); utl_http.write_raw(l_http_request, utl_raw.cast_to_raw(l_buffer)); l_offset := l_offset + l_amount; end loop; dbms_lob.createtemporary(v_blob, true, dbms_lob.call); dbms_lob.open(v_file, dbms_lob.lob_readonly); dbms_lob.open(v_blob, dbms_lob.lob_readwrite); v_length := dbms_lob.getlength(v_file); dbms_lob.loadfromfile(v_blob, v_file, v_length); while v_offset v_length loop dbms_lob.read(v_blob, v_amount, v_offset, v_buffer); utl_http.write_raw(l_http_request, v_buffer); v_offset := v_offset + v_amount; end loop; dbms_lob.close(v_file); dbms_lob.close(v_blob); l_request_body := l_newline || l_newline || '--' || lco_boundary || l_newline || 'Content-Disposition: form-data; name="payload"' || l_newline || l_newline || '{"name":"transaction created from Oracle","documents":[{"name":"document1"}]}' || l_newline || '--' || lco_boundary || '--'; l_request_body_length := dbms_lob.getlength(l_request_body); l_offset := 1; while l_offset l_request_body_length loop dbms_lob.read(l_request_body, l_amount, l_offset, l_buffer); utl_http.write_raw(l_http_request, utl_raw.cast_to_raw(l_buffer)); l_offset := l_offset + l_amount; end loop; l_http_response := utl_http.get_response(l_http_request); dbms_output.put_line('Response> Status Code: ' || l_http_response.status_code); dbms_output.put_line('Response> Reason Phrase: ' || l_http_response.reason_phrase); dbms_output.put_line('Response> HTTP Version: ' || l_http_response.http_version); for i in 1 .. utl_http.get_header_count(l_http_response) loop utl_http.get_header(l_http_response, i, l_response_header_name, l_response_header_value); dbms_output.put_line('Response> ' || l_response_header_name || ': ' || l_response_header_value); end loop; utl_http.read_text(l_http_response, l_response_body, 32767); dbms_output.put_line('Response body>'); dbms_output.put_line(l_response_body); if l_http_request.private_hndl is not null then utl_http.end_request(l_http_request); end if; if l_http_response.private_hndl is not null then utl_http.end_response(l_http_response); end if; exception when others then if l_http_request.private_hndl is not null then utl_http.end_request(l_http_request); end if; if l_http_response.private_hndl is not null then utl_http.end_response(l_http_response); end if; raise; end create_package2; /And BTW, the API reference site is up recently, go check there for REST API reference and JSON schema. Hope this could help! DuoReply to: Sample code to send pdf file via rest api
Tuesday, July 30, 2019 at 01:11amReply to: Sample code to send pdf file via rest api
Tuesday, July 30, 2019 at 05:02amReply to: Sample code to send pdf file via rest api
Thursday, August 8, 2019 at 10:14pmReply to: Sample code to send pdf file via rest api
Friday, August 9, 2019 at 05:40amReply to: Sample code to send pdf file via rest api
Monday, August 12, 2019 at 02:36amReply to: Sample code to send pdf file via rest api
Monday, August 12, 2019 at 04:47amv_file bfile := bfilename('MYDIR', 'SampleDoc.pdf');- then loaded the file to a blob:dbms_lob.createtemporary(v_blob, true, dbms_lob.call); dbms_lob.open(v_file, dbms_lob.lob_readonly); dbms_lob.open(v_blob, dbms_lob.lob_readwrite); v_length := dbms_lob.getlength(v_file); dbms_lob.loadfromfile(v_blob, v_file, v_length);- when building the request body, use dbms_lob.read() function to write certain length of a blob into a v_buffer, then use utl_http.write_raw() function to output the buffer to a plain text:while v_offset v_length loop dbms_lob.read(v_blob, v_amount, v_offset, v_buffer); utl_http.write_raw(l_http_request, v_buffer); v_offset := v_offset + v_amount; end loop; dbms_lob.close(v_file); dbms_lob.close(v_blob);I used three while loops to build the request, where the second one was used to output the file. (2)how did I derive the value for lco_boundary variable: I simply generated a random string token for the boundary, you can use the online tools like this or invoke the built-in PL SQL functions to do so.Reply to: Sample code to send pdf file via rest api
Wednesday, August 14, 2019 at 02:27amReply to: Sample code to send pdf file via rest api
Wednesday, August 14, 2019 at 06:04am{ "role":"Role1", "name": "approval2_name", "id": "approval2_id", "fields":[ { "name": "Tejaswi", "type": "SIGNATURE", "id": "Filename", "page": 1, "extract": true, "subtype": "FULLNAME" } ] }You can refer to the API Specification site for all available attributes in JSON schema. DuoReply to: Sample code to send pdf file via rest api
Wednesday, August 14, 2019 at 06:11amReply to: Sample code to send pdf file via rest api
Wednesday, August 14, 2019 at 08:52amReply to: Sample code to send pdf file via rest api
Wednesday, August 14, 2019 at 09:08amReply to: Sample code to send pdf file via rest api
Monday, August 19, 2019 at 05:19amReply to: Sample code to send pdf file via rest api
Monday, August 19, 2019 at 06:22amReply to: Sample code to send pdf file via rest api
Tuesday, August 20, 2019 at 07:29pmReply to: Sample code to send pdf file via rest api
Wednesday, August 21, 2019 at 04:28am"extractAnchor": { "text": "VP – Materials.", "index": 0, "width": 100, "height": 45, "anchorPoint": "TOPLEFT", "characterIndex": 0, "leftOffset": -5, "topOffset": -50 }