2017-07-04 16 views
0

Docusign APIへのリクエストをいくつか作成していますが、エラーメッセージ{"errorCode": "UNSPECIFIED_ERROR"、 "message": " Base-64文字の配列または文字列です。 }電子メールで電子署名リクエストを送信する方法でファイルを送信しようとしているとき。Docusign電子メールでの署名リクエスト - base64ファイルの内容のエラー

私がリクエストボディで送信しています以下のJSON:

{ 
"documents": [ 
    { 
     "documentBase64": "base64 encoded file...", 
     "documentId": "1", 
     "fileExtension": "pdf", 
     "name": "FILENAME.pdf" 
    } 
], 
"emailSubject": "Assinatura de documento requerida", 
"recipients": { 
    "signers": [ 
     { 
      "email": "[email protected]", 
      "name": "DiegoLopes", 
      "recipientId": "1", 
      "routingOrder": "1", 
      "tabs": { 
       "dateSignedTabs": [ 
        { 
         "anchorString": "signer1date", 
         "anchorYOffset": "-6", 
         "fontSize": "Size12", 
         "name": "Date Signed", 
         "recipientId": "1", 
         "tabLabel": "date_signed" 
        } 
       ], 
       "fullNameTabs": [ 
        { 
         "anchorString": "signer1name", 
         "anchorYOffset": "-6", 
         "fontSize": "Size12", 
         "name": "Full Name", 
         "recipientId": "1", 
         "tabLabel": "Full Name" 
        } 
       ], 
       "signHereTabs": [ 
        { 
         "anchorString": "signer1sig", 
         "anchorUnits": "mms", 
         "anchorXOffset": "0", 
         "anchorYOffset": "0", 
         "name": "Please sign here", 
         "optional": "false", 
         "recipientId": "1", 
         "scaleValue": 1, 
         "tabLabel": "signer1sig" 
        } 
       ] 
      } 
     } 
    ] 
}, 
"status": "sent" 

}

いくつかの追加情報。私はASPの古典的な呼び出しでこの要求をしています。ログイン情報とトークンデータを取得するにはすでにうまく動作しています。これは、リクエストを送信する方法I "mとする。

<% 
response.ContentType="application/json" 

dim token 
dim baseUrl 
dim usrName 
dim usrPwd 
dim usrIntegKey 
dim receiptName 
dim receiptEmail 
dim docName 
dim docContent 

usrName  = request.QueryString("username") 
usrPwd   = request.QueryString("password") 
usrIntegKey  = request.QueryString("integratorKey") 
token   = request.QueryString("token") 
baseUrl   = request.QueryString("baseUrl") 
receiptName  = request.form("receiptName") 
receiptEmail = request.form("receiptEmail") 
docName   = request.form("docToSign") 
docContent  = replace(request.form("docContent"),"+", " ") 


dataSent = "" 
dataSent = dataSent & "{" & chr(13) 
dataSent = dataSent & """documents"": [" & chr(13) 
dataSent = dataSent & "{" & chr(13) 
dataSent = dataSent & """documentBase64"": """ & docContent & """," & chr(13) 
dataSent = dataSent & """documentId"": ""1""," & chr(13) 
dataSent = dataSent & """fileExtension"": ""pdf""," & chr(13) 
dataSent = dataSent & """name"": ""NDA.pdf""" & chr(13) 
dataSent = dataSent & "}" & chr(13) 
dataSent = dataSent & "]," & chr(13) 
dataSent = dataSent & """emailSubject"": ""Assinatura de documento requerida""," & chr(13) 
dataSent = dataSent & """recipients"": {" & chr(13) 
dataSent = dataSent & """signers"": [" & chr(13) 
dataSent = dataSent & "{" & chr(13) 
dataSent = dataSent & """email"": """ & receiptEmail &"""," & chr(13) 
dataSent = dataSent & """name"": """ & receiptName & """," & chr(13) 
dataSent = dataSent & """recipientId"": ""1""," & chr(13) 
dataSent = dataSent & """routingOrder"": ""1""," & chr(13) 
dataSent = dataSent & """tabs"": {" & chr(13) 
dataSent = dataSent & """dateSignedTabs"": [" & chr(13) 
dataSent = dataSent & "{" & chr(13) 
dataSent = dataSent & """anchorString"": ""signer1date""," & chr(13) 
dataSent = dataSent & """anchorYOffset"": ""-6""," & chr(13) 
dataSent = dataSent & """fontSize"": ""Size12""," & chr(13) 
dataSent = dataSent & """name"": ""Date Signed""," & chr(13) 
dataSent = dataSent & """recipientId"": ""1""," & chr(13) 
dataSent = dataSent & """tabLabel"": ""date_signed""" & chr(13) 
dataSent = dataSent & "}," & chr(13) 
dataSent = dataSent & "]," & chr(13) 
dataSent = dataSent & """fullNameTabs"": [" & chr(13) 
dataSent = dataSent & "{" & chr(13) 
dataSent = dataSent & """anchorString"": ""signer1name""," & chr(13) 
dataSent = dataSent & """anchorYOffset"": ""-6""," & chr(13) 
dataSent = dataSent & """fontSize"": ""Size12""," & chr(13) 
dataSent = dataSent & """name"": ""Full Name""," & chr(13) 
dataSent = dataSent & """recipientId"": ""1""," & chr(13) 
dataSent = dataSent & """tabLabel"": ""Full Name""" & chr(13) 
dataSent = dataSent & "}" & chr(13) 
dataSent = dataSent & "]," & chr(13) 
dataSent = dataSent & """signHereTabs"": [" & chr(13) 
dataSent = dataSent & "{" & chr(13) 
dataSent = dataSent & """anchorString"": ""signer1sig""," & chr(13) 
dataSent = dataSent & """anchorUnits"": ""mms""," & chr(13) 
dataSent = dataSent & """anchorXOffset"": ""0""," & chr(13) 
dataSent = dataSent & """anchorYOffset"": ""0""," & chr(13) 
dataSent = dataSent & """name"": ""Please sign here""," & chr(13) 
dataSent = dataSent & """optional"": ""false""," & chr(13) 
dataSent = dataSent & """recipientId"": ""1""," & chr(13) 
dataSent = dataSent & """scaleValue"": 1," & chr(13) 
dataSent = dataSent & """tabLabel"": ""signer1sig""" & chr(13) 
dataSent = dataSent & "}" & chr(13) 
dataSent = dataSent & "]" & chr(13) 
dataSent = dataSent & "}" & chr(13) 
dataSent = dataSent & "}" & chr(13) 
dataSent = dataSent & "]" & chr(13) 
dataSent = dataSent & "}," & chr(13) 
dataSent = dataSent & """status"": ""sent""" & chr(13) 
dataSent = dataSent & "}" 


Set HttpReq = Server.CreateObject("MSXML2.ServerXMLHTTP") 
HttpReq.open "POST", baseUrl & "/envelopes", False 


HttpReq.SetRequestHeader "Authentication", "Bearer " & token 
HttpReq.SetRequestHeader "Accept", "application/json" 
HttpReq.SetRequestHeader "Content-type", "application/json" 

HttpReq.SetRequestHeader "X-DocuSign-Authentication", "{ ""Username"": """ & usrName & """, ""Password"": """ & usrPwd & """, ""IntegratorKey"": """ & usrIntegKey & """ }" 

response.Write(dataSent) 

HttpReq.send(dataSent) 

'response.Write(HttpReq.ResponseText) 

%>

私はすでに計算しましたし、エンコードされた値が有効なbase64のコンテンツである。

誰かがこの上で私を助けてくださいことはできますか?

+0

ファイルへのリンクを投稿してください。ファイルを正しくエンコードしていないようです。 –

答えて

0

私は、これはファイルのコンテンツをエンコードしているJS関数です...私のマシンで簡単なPDFのテストファイルを使用してテストをしました:

var handleFileSelect = function(evt) { 
var files = evt.target.files; 
var file = files[0]; 

if (files && file) { 
    var reader = new FileReader(); 

    reader.onload = function(readerEvt) { 
     var binaryString = readerEvt.target.result; 
     document.getElementById("hidden_doc").value = btoa(binaryString); 
    }; 

    reader.readAsBinaryString(file); 
} 
var fullPath = document.getElementById('document').value; 
if (fullPath) { 
    var startIndex = (fullPath.indexOf('\\') >= 0 ? fullPath.lastIndexOf('\\') : fullPath.lastIndexOf('/')); 
    fileName = fullPath.substring(startIndex); 
    if (fileName.indexOf('\\') === 0 || fileName.indexOf('/') === 0) { 
     fileName = fileName.substring(1); 
    } 
} 

};また

、あなたが見ることができるように、私は、ファイルを選択し、ファイルの入力タイプがあります。

<input type="file" id="document" accept=".pdf"/> 
0

私はすでに問題を解決してきました。私のbase64関数が間違っていた。

今、私は次の関数を使用していますし、それが正常に働いている:すべてのあなたの助けを

function previewFile() { 
var preview = document.getElementById("hidden_doc"); 
var file = document.querySelector('input[type=file]').files[0]; 
var reader = new FileReader(); 

reader.addEventListener("load", function() { 
    preview.value = reader.result.split(',')[1]; 
}, false); 

if (file) { 
    reader.readAsDataURL(file); 
} 

var fullPath = document.getElementById('document').value; 
if (fullPath) { 
    var startIndex = (fullPath.indexOf('\\') >= 0 ? fullPath.lastIndexOf('\\') : fullPath.lastIndexOf('/')); 
    fileName = fullPath.substring(startIndex); 
    if (fileName.indexOf('\\') === 0 || fileName.indexOf('/') === 0) { 
     fileName = fileName.substring(1); 
    } 
} 

} 

感謝を。

関連する問題