内容类型不支持json

时间:2013-11-22 15:58:15

标签: php json curl

我正在使用以下代码进行api调用以docusign删除收件人:

$data = "{
\"signers\": [{
\"recipientId\": \"1\"
}]
}";  

$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/$accountId/envelopes/$envelopeId/recipients";


$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: multipart/form-data;boundary=myboundary',
  'Content-Length: ' . strlen($requestBody),
  "X-DocuSign-Authentication: $header" )                                                                       
);

$json_response = curl_exec($curl); 
$response = json_decode($json_response, true);


$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);

我收到以下错误:调用webservice时出错,状态为:400错误文本为 - > {“errorCode”:“INVALID_CONTENT_TYPE”,“message”:“不支持指定的内容类型。” }。感谢

0 个答案:

没有答案