PDF_VALIDATION_FAILED - 在DocuSign POST信封上

时间:2017-08-10 22:59:41

标签: node.js docusignapi

我正在尝试使用此tutorial发送信封请求。我正在使用NodeJS尝试在base64Format中硬编码PDFFile,但我得到的是PDF_VALIDATION_FAILED。 这是我的代码:

options.multipart = [{
        "Content-Type": "application/json",
        "Content-Disposition": "form-data",
        "body": JSON.stringify(body),
    }, {
        "Content-Type": "application/pdf",
        'Content-Disposition': 'file; filename="' + documentName + '"; documentId=1',
        "body": "data:application/pdf;base64,JVBERi0xLjMKMyAwIG9iago8PC9UeXBlIC9QYWdlCi9QYXJlbnQgMSAwIFIKL1Jlc291cmNlcyAyIDAgUgovTWVkaWFCb3ggWzAgMCA1OTUuMjggODQxLjg5XQovQ29udGVudHMgNCAwIFIKPj4KZW5kb2JqCjQgMCBvYmoKPDwvTGVuZ3RoIDcyPj4Kc3RyZWFtCjAuNTcgdwowIEcKQlQKL0YxIDE2IFRmCjE4LjQgVEwKMCBnCjI4LjM1IDgxMy41NCBUZAooSGVsbG8gd29ybGQhKSBUagpFVAplbmRzdHJlYW0KZW5kb2JqCjEgMCBvYmoKPDwvVHlwZSAvUGFnZXMKL0tpZHMgWzMgMCBSIF0KL0NvdW50IDEKPj4KZW5kb2JqCjUgMCBvYmoKPDwvQmFzZUZvbnQvSGVsdmV0aWNhL1R5cGUvRm9udAovRW5jb2RpbmcvV2luQW5zaUVuY29kaW5nCi9TdWJ0eXBlL1R5cGUxPj4KZW5kb2JqCjYgMCBvYmoKPDwvQmFzZUZvbnQvSGVsdmV0aWNhLUJvbGQvVHlwZS9Gb250Ci9FbmNvZGluZy9XaW5BbnNpRW5jb2RpbmcKL1N1YnR5cGUvVHlwZTE+PgplbmRvYmoKNyAwIG9iago8PC9CYXNlRm9udC9IZWx2ZXRpY2EtT2JsaXF1ZS9UeXBlL0ZvbnQKL0VuY29kaW5nL1dpbkFuc2lFbmNvZGluZwovU3VidHlwZS9UeXBlMT4+CmVuZG9iago4IDAgb2JqCjw8L0Jh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wMDA3NjggMDAwMDAgbiAKMDAwMDAwMDg2MiAwMDAwMCBuIAowMDAwMDAwOTU5IDAwMDAwIG4gCjAwMDAwMDEwNjAgMDAwMDAgbiAKMDAwMDAwMTE1MyAwMDAwMCBuIAowMDAwMDAxMjQ1IDAwMDAwIG4gCjAwMDAwMDEzMzkgMDAwMDAgbiAKMDAwMDAwMTQzNyAwMDAwMCBuIAowMDAwMDAxNzY4IDAwMDAwIG4gCjAwMDAwMDE4NTkgMDAwMDAgbiAKdHJhaWxlcgo8PAovU2l6ZSAyMAovUm9vdCAxOSAwIFIKL0luZm8gMTggMCBSCj4+CnN0YXJ0eHJlZgoxOTYzCiUlRU9G"
    }
    ];

我正在按照这个确切的例子,除了我已经用这个替换了fs.readFileSync(documentName)的多部分中的正文:

"data:application/pdf;base64,JVBERi0xLjMKMyAwIG9iago8PC9UeXBlIC9QYWdlCi9QYXJlbnQgMSAwIFIKL1Jlc291cmNlcyAyIDAgUgovTWVkaWFCb3ggWzAgMCA1OTUuMjggODQxLjg5XQovQ29udGVudHMgNCAwIFIKPj4KZW5kb2JqCjQgMCBvYmoKPDwvTGVuZ3RoIDcyPj4Kc3RyZWFtCjAuNTcgdwowIEcKQlQKL0YxIDE2IFRmCjE4LjQgVEwKMCBnCjI4LjM1IDgxMy41NCBUZAooSGVsbG8gd29ybGQhKSBUagpFVAplbmRzdHJlYW0KZW5kb2JqCjEgMCBvYmoKPDwvVHlwZSAvUGFnZXMKL0tpZHMgWzMgMCBSIF0KL0NvdW50IDEKPj4KZW5kb2JqCjUgMCBvYmoKPDwvQmFzZUZvbnQvSGVsdmV0aWNhL1R5cGUvRm9udAovRW5jb2RpbmcvV2luQW5zaUVuY29kaW5nCi9TdWJ0eXBlL1R5cGUxPj4KZW5kb2JqCjYgMCBvYmoKPDwvQmFzZUZvbnQvSGVsdmV0aWNhLUJvbGQvVHlwZS9Gb250Ci9FbmNvZGluZy9XaW5BbnNpRW5jb2RpbmcKL1N1YnR5cGUvVHlwZTE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DAxMTggMDAwMDAgbiAKMDAwMDAwMDI5NSAwMDAwMCBuIAowMDAwMDAwMzg1IDAwMDAwIG4gCjAwMDAwMDA0ODAgMDAwMDAgbiAKMDAwMDAwMDU3OCAwMDAwMCBuIAowMDAwMDAwNjgwIDAwMDAwIG4gCjAwMDAwMDA3NjggMDAwMDAgbiAKMDAwMDAwMDg2MiAwMDAwMCBuIAowMDAwMDAwOTU5IDAwMDAwIG4gCjAwMDAwMDEwNjAgMDAwMDAgbiAKMDAwMDAwMTE1MyAwMDAwMCBuIAowMDAwMDAxMjQ1IDAwMDAwIG4gCjAwMDAwMDEzMzkgMDAwMDAgbiAKMDAwMDAwMTQzNyAwMDAwMCBuIAowMDAwMDAxNzY4IDAwMDAwIG4gCjAwMDAwMDE4NTkgMDAwMDAgbiAKdHJhaWxlcgo8PAovU2l6ZSAyMAovUm9vdCAxOSAwIFIKL0luZm8gMTggMCBSCj4+CnN0YXJ0eHJlZgoxOTYzCiUlRU9G"

我错过了文件中的转换/加密吗?

2 个答案:

答案 0 :(得分:1)

您还应指定Content-Transfer-Encoding: base64

options.multipart = [
    {
        "Content-Type": "application/json",
        "Content-Disposition": "form-data",
        "body": JSON.stringify(body),
    },
    {
        "Content-Type": "application/pdf",
        'Content-Disposition': 'file;filename="' + documentName + '"; documentId=1',
        "Content-Transfer-Encoding": "base64",
        "body": "<Base64 Bytes here>"
    }
];

同样不需要data:application/pdf;base64

答案 1 :(得分:1)

将多部分哑剧信息放在一起很麻烦。但其中一个优点是格式支持二进制。即,你必须对它进行Base64编码。

我尝试没有 Base64编码。

(如配方所示。)