简体   繁体   中英

DocuSign Base64 PDF Conversion issue

I got a Bad Request:400 error while sending base 64 PDF bytes to DocuSign SOAP API(createAndSendEnvelope). Please help me in this issue.

Below is the code for converting PDF file into base 64 bytes:

File fFile = new File(pDFFileName); 
byte[] bBytes = FileUtils.readFileToByteArray(fFile); 
byte[] bBytesEnc = Base64.getEncoder().encode(bBytes);  
documents.setPDFBytes(bBytesEnc);

I don't think you need to do Base64 of the byte array. I have below code without base64 and its working fine for me:

        File f = new File(pDFFileName); 

        FileInputStream fs = new FileInputStream(f);
        byte[] pdfBytes = new byte[(int) f.length()];
        fs.read(pdfBytes);
        fs.close();
        Document doc = new Document();
        doc.setPDFBytes(pdfBytes);

byte[] fileBytes = System.IO.File.ReadAllBytes(@"C:\\Users\\%username%\\Desktop\\File.PDF"); // Add a document to the envelope Document doc = new Document(); doc.DocumentBase64 = System.Convert.ToBase64String(fileBytes); doc.Name = "TestFile.pdf"; doc.DocumentId = "3";

我这样做就是这样,对我来说这是工作。

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM