何かすべての助けがありがとう!Rails 4 HTTParty Docusign API無効なベース64文字列
私はDocuSignのAPIにHTTPartyを使用して封筒要求ポストを送信すると述べてエラーになっておくのです: The input is not a valid Base-64 string as it contains a non-base 64 character
をここでは私のHTTPポストです:
req = HTTParty.post(baseUrl, body: { "status": "sent", "emailSubject": "Send this already", "documents": [{ "documentId": "1", "name": "test.pdf" }], "recipients": { "signers": [{ "name": "joe dirt", "email": "[email protected]", "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\":\"[email protected]\", \"recipientId\":\"1\", \"routingOrder\":\"1\", \"tabs\":{ \"signHereTabs\"[{ \"xPosition\":\"150\", \"yPosition\":\"200\", \"documentId\":\"1\", \"pageNumber\":\"2\" }] } }] }"
私のような作るとき、私は私のベースURLのために成功した要求を得る:
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
上記のオブジェクトはJSONオブジェクト全体ですか? –
さて、それはする必要があります。ご覧のとおり、変換を行うために、htttopartyリクエストに.to_json関数を追加しました。私のサーバーでリクエストがどのように見えるかを追加します。 –
なぜ '' X-DocuSign-Authentication'に ''''値を使用していますか? 「ユーザー名」: 「パスワード」:「blah」、 「IntegratorKey」:「blah-blah-blah-blah-blah」「 」を確認してください。 '' –