0

我已经在 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”:“请求正文丢失或格式不正确。输入字符串的格式不正确。” }。谁能告诉我是什么问题?

4

1 回答 1

0

开发人员遇到了 json 格式的问题。有一些不需要的值被删除了,现在它正在工作(基于上面的评论)。确保将其标记为已回答。

于 2019-08-14T20:34:19.297 回答