Hi I am in the same situation.
I still can't add custom fields using API.
This is my code:
$fields_array = array(
"fileInfos" => array([
"transientDocumentId" => $transientDocumentId
]),
"name" => "PDF testing",
"participantSetsInfo" => array([
"memberInfos" => array([
"email" => "myemail@test.com"
]),
"order" => 1,
"role" => "SIGNER"
]),
"mergeFieldInfo" => array([
"defaultValue" => "Test",
"fieldName" => "sigBlock2"
]),
"signatureType" => "ESIGN",
"state" => "DRAFT" //<-- if I use AUTHORING i can't assign custom fields
);
$postdata = json_encode($fields_array);
$resource = curl_init();
curl_setopt_array($resource, array(
CURLOPT_URL => "https://api.eu1.echosign.com/api/rest/v6/agreements",
CURLOPT_HTTPHEADER => $header, //<---contain token etc....
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_RETURNTRANSFER => true,
CURLOPT_POST => true,
CURLOPT_POSTFIELDS => $postdata,
CURLOPT_SSL_VERIFYHOST => false,
CURLOPT_SSL_VERIFYPEER => false
));
$res = curl_exec($resource);
$result = json_decode($res,true);
$id = $result['id'];
Then set custom fields:
$fields_array = array(
"fields" => [array(
"locations" => [array(
"height" => 36,
"left" => 75,
"pageNumber" => 2,
"top" => 200,
"width" => 150
)],
"contentType" => "DATA",
"name" => "sigBlock1",
"backgroundColor" => "#CCCCCC",
"inputType" => "TEXT_FIELD",
"required" => true,
"visible" => true
)]
);
$postdata = json_encode($fields_array);
$resource = curl_init();
curl_setopt_array($resource, array(
CURLOPT_URL => "https://api.eu1.echosign.com/api/rest/v6/agreements/" . $id . "/formFields",
CURLOPT_HTTPHEADER => $header,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_RETURNTRANSFER => true,
CURLOPT_CUSTOMREQUEST => "PUT",
CURLOPT_POSTFIELDS => $postdata,
CURLOPT_SSL_VERIFYHOST => false,
CURLOPT_SSL_VERIFYPEER => false
));
$res = curl_exec($resource);
Then change status to IN_PROGRESS to send email:
$fields_array = array(
"state" => "IN_PROCESS"
);
$postdata = json_encode($fields_array);
$resource = curl_init();
curl_setopt_array($resource, array(
CURLOPT_URL => "https://api.eu1.echosign.com/api/rest/v6/agreements/" . $id . "/state",
CURLOPT_HTTPHEADER => $header,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_RETURNTRANSFER => true,
CURLOPT_CUSTOMREQUEST => "PUT",
CURLOPT_POSTFIELDS => $postdata,
CURLOPT_SSL_VERIFYHOST => false,
CURLOPT_SSL_VERIFYPEER => false
));
$res = curl_exec($resource);
So i get email with link to sign the document....but i don't see my custom field! I always see default sign field appended at the end of document.
Where I wrong?