I am trying to upgrade some older code that uses Docusign’s username/password method of authentication for their Rest API to the newer OAuth version.
We’re using this for an automated service so JWT makes sense. Our existing code uses a prebuilt template in the Docusign account and populates it and sends it to the recipient. I have created a JWT Bearer Token and tried implementing it using cURL but I just get the response “false”. I am at a loss here. Docusign hasn’t been much help so far, their documentation is overwhelming. This runs in a WordPress functions.php file, it should be simple. i worked for years the old way.
$fields = [];
$initials = [];
$checkboxes = [];
$recipients = ['[email protected]'];
$templateID = "2ce6c87b-****";
$accountId = '0cec5847-****';
$integratorKey = "d2c3fbe6-****";
$data = array(
'accountId' => $accountID,
'templateId' => $templateID,
'templateRoles' => $recipients,
'emailSubject' => 'Important Forms',
'status' => 'sent',
);
$data_string = json_encode($data);
$curl = curl_init();
curl_setopt_array($curl, array(
CURLOPT_URL => ' https://demo.docusign.net/restapi/v2.1/accounts/123456789/envelopes',
CURLOPT_RETURNTRANSFER => true,
CURLOPT_POST => true,
CURLOPT_POSTFIELDS => $data_string,
CURLOPT_HTTPHEADER => array ('Authorization: Bearer eyJ0****'),
));
$response = curl_exec($curl);
$status = curl_getinfo($curl, CURLINFO_HTTP_CODE);
echo json_encode($response);
curl_close($curl);
I am expecting some response from the cUrl call, even a 404. I literally get “false”.