0

何かすべての助けがありがとう!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

+0

上記のオブジェクトはJSONオブジェクト全体ですか? –

+0

さて、それはする必要があります。ご覧のとおり、変換を行うために、htttopartyリクエストに.to_json関数を追加しました。私のサーバーでリクエストがどのように見えるかを追加します。 –

+0

なぜ '' X-DocuSign-Authentication'に ''''値を使用していますか? 「ユーザー名」: 「パスワード」:「blah」、 「IntegratorKey」:「blah-blah-blah-blah-blah」「 」を確認してください。 '' –

答えて

0

提供されているソリューションはどれも実際には役に立たなかったが、自分のテンプレート上でコードを変更して送信リクエストを受け取ることができた。なぜ「クイックスタート」プロセスが私にとってうまくいかなかったのか分かりません。

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

ヘッダーに"Content-Transfer-Encoding" => "Base64"と設定しています。それを取り除く。

+0

その行を削除した場合、 ''入力は有効ではありませんBase-64文字列には非ベース64文字が含まれているので、 \ "\ r \ n}" –

+0

Andrewが正しいです。コンテンツタイプはjsonです.jsonオブジェクトの1つのフィールドのみがbase64でエンコードされています。/DocuSignロギング機能のヘッダーとデータを受け取った –

+0

私はdocusignのドキュメントへのリンクを追加しました。 y認証はうまくいっているようだが、それは身体の中に入って、私が問題を抱えているところだと感じている。 –

関連する問題