我已在docusign上手动创建了一个主帐户,现在我想使用此帐户创建新用户。这是我的代码:
$integratorKey = 'XXXX-XXXXX-XXXX-XXXX-XXXX-XXXXXXXX';
$email = 'my-email';
$password = 'XXXX';
$name = 'User';
$header = "<DocuSignCredentials><Username>" . $email . "</Username><Password>" . $password . "</Password><IntegratorKey>" . $integratorKey . "</IntegratorKey></DocuSignCredentials>";
$data = '{
"newUsers":[{
"activationAccessCode":"",
"email":"my-email@gmail.com",
"enableConnectForUser":"",
"firstName":"",
"forgottenPasswordInfo":{
"forgottenPasswordAnswer1":"",
"forgottenPasswordAnswer2":"",
"forgottenPasswordAnswer3":"",
"forgottenPasswordAnswer4":"",
"forgottenPasswordQuestion1":"",
"forgottenPasswordQuestion2":"",
"forgottenPasswordQuestion3":"",
"forgottenPasswordQuestion4":""
},
"groupList":{
"groupId":"",
"groupId":""
},
"lastName":"",
"middleName":"",
"password":"",
"sendActivationOnInvalidLogin":"",
"suffixName":"",
"title":"",
"userName":"username",
"userSettings":[{
"name":"",
"value":""
}]
}]
}';
$requestBody = "\r\n"
."\r\n"
."--myboundary\r\n"
."Content-Type: application/json\r\n"
."Content-Disposition: form-data\r\n"
."\r\n"
."$data\r\n"
."--myboundary--\r\n"
."\r\n";
$url = "https://demo.docusign.net/restapi/v2/accounts";
$curl = curl_init($url);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
curl_setopt($curl, CURLOPT_POST, true);
curl_setopt($curl, CURLOPT_POSTFIELDS, $requestBody);
curl_setopt($curl, CURLOPT_HTTPHEADER, array(
'Content-Type: application/json',
'Content-Length: ' . strlen($requestBody),
"X-DocuSign-Authentication: $header" )
);
$json_response = curl_exec($curl);
$status = curl_getinfo($curl, CURLINFO_HTTP_CODE);
if ( $status != 201 ) {
echo "error calling webservice, status is:" . $status . "\nerror text is --> ";
print_r($json_response); echo "\n";
exit(-1);
}
$response = json_decode($json_response, true);
var_dump($response);
我得到的错误是:{“errorCode”:“INVALID_REQUEST_BODY”,“message”:“请求正文丢失或格式不正确。输入字符串的格式不正确。” }。谁能告诉我这是什么问题?
答案 0 :(得分:0)
开发人员的json格式有问题。有一些不需要的值已被删除,并且现在可以正常工作(基于上面的评论)。确保将其标记为已回答。