Rails 4 HTTParty Docusign api 无效的 base 64 字符串

Rails 4 HTTParty Docusign api invalid base 64 string

非常感谢任何帮助!

我正在使用 HTTParty 向 Docusign api 发送一个信封请求 post 并不断收到一个错误,指出: The input is not a valid Base-64 string as it contains a non-base 64 character

这是我的 HTTP post:

req = HTTParty.post(baseUrl, body: { "status": "sent", "emailSubject": "Send this already", "documents": [{ "documentId": "1", "name": "test.pdf" }], "recipients": { "signers": [{ "name": "joe dirt", "email": "joe.dirte@gmail.com", "recipientId": "1", "routingOrder": "1", "tabs": { "signHereTabs": [{ "xPosition": "150", "yPosition": "200", "documentId": "1", "pageNumber": "2" }], } }] } }.to_json, headers: { "Content-Type" => "application/json", "Content-Transfer-Encoding" => "Base64", 'X-DocuSign-Authentication' => '{ "Username" : "blah-blahblah-blah-blah-blah", "Password" : "blah", "IntegratorKey" : "blah-blah-blah-blah-blah" }' }, :debug_output => $stdout)

调试器吐出以下内容:

"HTTP/1.1 400 Bad Request\r\n" "Cache-Control: no-cache\r\n" "Pragma: no-cache\r\n" "Content-Length: 226\r\n" "Content-Type: application/json; charset=utf-8\r\n" "Expires: -1\r\n"

这是我的服务器中显示的完整请求:

<- "POST /restapi/v2/accounts/1906554/envelopes HTTP/1.1\r\nAccept: application/json\r\nContent-Type: application/json\r\nX-Docusign-Authentication: { \n \"Username\" : \"blah-blah-blah-b;ah-blah\", \n \"Password\" : \"blah\", \n \"IntegratorKey\" : \"blah-blah-blah-blah-blah\" \n }\r\nConnection: close\r\nHost: demo.docusign.net\r\nContent-Length: 394\r\n\r\n" <-"{ \"status\":\"sent\", \"emailSubject\":\"Example of one recipient, type signer\", \"documents\":[{ \"documentId\":\"1\", \"name\":\"RE Ally MNDA_MAster.pdf\", \"documentBase64\":\"base64 document bytes...\"}], \"recipients\":{\"signers\":[{ \"name\":\"joe dirt\", \"email\":\"joe.dirte@gmail.com\", \"recipientId\":\"1\", \"routingOrder\":\"1\", \"tabs\":{ \"signHereTabs\"[{ \"xPosition\":\"150\", \"yPosition\":\"200\", \"documentId\":\"1\", \"pageNumber\":\"2\" }] } }] }"

根据他们的文档,当我这样做时,我收到了对我的 baseURL 的成功请求:

HTTParty.get('https://demo.docusign.net/restapi/v2/login_information', headers: {
                'Accept' => 'application/json',
                'Content-Type' => 'application/json',
                'X-DocuSign-Authentication' => '{
                "Username" : "blah-bla-blah-bla-blah",
                "Password" : "blahword1",
                "IntegratorKey" : "blah-blah-blah-blah-blah"
                }'
                }
        )

This is how docusign is expecting my post to look

您正在 headers 中设置 "Content-Transfer-Encoding" => "Base64"。删除那个。

None 提供的解决方案确实对我有用,但我能够通过更改 body 上的代码在我的模板上获得发送请求。不知道为什么 'Quick Start' 过程对我不起作用。

body:  {
            "emailSubject": "DocuSign API call - Request Signature - Boom",
            "templateId": "blahblah-blah-blah-blah-blahblah",
            "templateRoles": [{
                "email": "blah.l.lablah@gmail.com",
                "name": "la Leunblahg",
                "title": "El Hefe",
                "roleName": "Employee"
            }],
            "status": "sent"
        }.to_json