非常基本的内容-如何通过REST API将文档发送到docusign?我只看到<文档字节在这里...>到处 [英] Very basic stuff - how do I send a document to docusign via REST API? I only see <document bytes go here...> everywhere

查看:81
本文介绍了非常基本的内容-如何通过REST API将文档发送到docusign?我只看到<文档字节在这里...>到处的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

您能告诉我下面的代码是否正确吗?

Can you tell me whether my code below is fine?

--MYBOUNDARY
Content-Type: application/pdf
Content-Disposition: file; filename="sample.pdf";documentid=1

{ 
[B@17f7be7b
}
--MYBOUNDARY--

[B @ 17f7be7b是java为我的pdf返回的byteArray(仅以只是一个示例为内容的pdf文件)。我刚刚将byteArray转换为String,并将其粘贴到此处。
我得到

The [B@17f7be7b is the byteArray returned by java for my pdf (pdf file with just "Just a sample" as content). I just converted that byteArray to String and I have pasted it here. I get

  "errorCode": "UNABLE_TO_LOAD_DOCUMENT",
  "message": "Unable to load the document. Unable to load Document(1). Error: the document is          corrupt, rebuilding failed"

请帮助我以正确的方式完成操作。

Pls help me with the right way of doing this.

推荐答案

您尚未发布相关的代码,因此调试起来更加困难,但从表面上看,您发布的文字至少有两个问题。一种是文档字节不应该用括号 { } 括起来。

You haven't posted the relevant code which makes it harder to debug, but on the surface there are at least two problems with the text you've posted. One is that the document bytes should not be enclosed with brackets { }.

接下来,您似乎无法正确地编码文档字节。 PDF原始字节将不会以 [B @ 1 ......开头。如果看不到您的代码,我只能说您需要检查一下您的状态。将PDF字节写入请求。

Next it does not look like you are encoding the document bytes correctly. The PDF raw bytes will not start with [B@1.......... Without seeing your code I can only say you need to review how you are writing the PDF bytes to the request.

如此之多的帖子显示 Document Bytes Go Here的原因是,在示例请求中包含一堆随机的,非人类可读的字符是非常无用的。如果您是程序员,并且了解将文档字节写入流的含义,那么您应该不会有任何问题。这是一个示例请求,再次省略了文件字节:

The reason why so many posts show "Document Bytes Go Here" is that it's pretty useless having a bunch of random, non-human readable characters in the sample request. If you are programmer and you understand what it means to write document bytes to a stream then you should understand no problem. Here is a sample request with once again the document bytes omitted:

POST https://demo.docusign.net/restapi/v2/accounts/123456/envelopes HTTP/1.1

X-DocuSign-Authentication: {"Username":"USERNAME","Password":"PASSWORD","IntegratorKey":"INTEGRATOR_KEY"}
Content-Type: multipart/form-data; boundary=BOUNDARY
Accept: application/json
Host: demo.docusign.net
Content-Length: 23414
Expect: 100-continue
Connection: Keep-Alive

--BOUNDARY
Content-Type: application/json
Content-Disposition: form-data

{
    "status": "sent",
    "emailBlurb": "Test Email Body",
    "emailSubject": "Test Email Subject",
    "documents": [
        {
            "name": "test.pdf",
            "documentId": "1",
            "order": "1"
        }
    ],
    "recipients": {
        "signers": [
            {
                "email": "test@domain.com ",
                "name": "John Doe",
                "recipientId": "1",
                "tabs": {
                    "signHereTabs": [
                        {
                            "xPosition": "100",
                            "yPosition": "100",
                            "documentId": "1",
                            "pageNumber": "1"
                        }
                    ]
                }
            }
        ]
    }
}

--BOUNDARY
Content-Type: application/pdf
Content-Disposition: file; filename="document.pdf"; documentid="1"

[document bytes removed]

--BOUNDARY--

上述请求将发送一个签名请求,该签名请求的签名者为一个收件人,并将一个签名选项卡放置在文档中的位置 100 右边的像素,而文档左上角的 100 像素。查看 DocuSign API演练,以获取有关如何完成此操作的代码示例,尤其是第四次演练在文档上请求签名会以6种不同的语言( PHP JavaScript Java C# Python Objective-C ),并附有说明:

The above request will send a signature request with one recipient of type signer and will place one signature tab on the document for them at location 100 pixels to the right and 100 pixels down from the top left of the document. Check out the DocuSign API Walkthroughs for code samples on how to accomplish this, in particular the 4th walkthrough Request Signature on a Document shows you exactly how to do this in 6 different languages (PHP, Javascript, Java, C#, Python, Objective-C) with instructions:

http://iodocs.docusign.com/APIWalkthroughs

这篇关于非常基本的内容-如何通过REST API将文档发送到docusign?我只看到<文档字节在这里...>到处的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆