Upload Document

Before each document can be signed, document need to be uploaded to the system and obtain a contract number. This contract number will be use during signing.

Sequence to call API for Upload Document

Source Code Sample

File uploadFile = new File("C:\\...\\abc.pdf");
String uploadFileHash = Utils.calculateHash(Files.readAllBytes(uploadFile.toPath()));
		   
String contractname_set="Test";

JSONObject jsonContractInfo = new JSONObject();
jsonContractInfo.put("contractnum","");
jsonContractInfo.put("contractname",contractname_set);
jsonContractInfo.put("signernum",1); 
		    
JSONObject signinfo1 = new JSONObject();
signinfo1.put("email", "chrischang@gmail.com");
signinfo1.put("authtype","0"); 
signinfo1.put("caprovide",1); 
signinfos.add(signinfo1);
		      
jsonContractInfo.put("signerinfo", signinfos);
jsonData = new JSONObject();
jsonData.put("uploadFileHash", uploadFileHash);
jsonData.put("type","pdf");
jsonData.put("contractInfo", jsonContractInfo);

String uploadFileData = Hex.encodeHexString(Utils.aesEcbPkcs5PaddingEncrypt(jsonData.toString(),apiSecret));
String uploadFileMac = Utils.calculateMac(uploadFileData,apiSecret);
Sample code to prepare raw data object for upload document

Request Body Creation

{
   "contractInfo": {
      "contractname": "Test",
      "signernum": 1,
      "contractnum": "",
      "signerinfo": [
         {
            "caprovide": "1",
            "email": "chrischang@gmail.com",
            "authtype": "0"}]
   },
   "uploadFileHash": "fa970522cc40f33d8a56d1af5e543595221698",
   "type": "pdf",
}

Example of Request

https://<domain>/signserver/v1/contract/file?accesstoken=1f710ee6&data=71dc5&mac=bb69344&uploadFile=b2ba4aa4b07b538f472e3ff9

Expected Response

{
           "contractnum":"C555873284EA879410A8F57383AB231E"
}

API reference Upload Document

How can we help?