How can I get the envelope draft with the data on form fields via REST API to show a preview on my system, I am using PHP API on DocuSign sandbox, but the PDF request-response with an error when the envelope id is in draft status.
<?php
$client = new http\Client;
$request = new http\Client\Request;
$request->setRequestUrl('https://demo.docusign.net/restapi/v2.1/accounts/7808658/envelopes/{{envelopeId}}/documents/{{documentId}}');
$request->setRequestMethod('GET');
$request->setOptions(array());
$request->setHeaders(array(
'X-DocuSign-Authentication' => '{"Username":"x@xxx.com","Password":"doOTcFj08wl/xO6uR2ZLX6+rOaE=","IntegratorKey": "xxxx-xxxx-xx-a075-xxx"}',
'Content-Type' => 'application/json'
));
$client->enqueue($request)->send();
$response = $client->getResponse();
echo $response->getBody();
I tried to make the request on the postman, but the response is an error when the envelope is in draft status.
$client = new http\Client;
$request = new http\Client\Request;
$request->setRequestUrl('https://demo.docusign.net/restapi/v2.1/accounts/7808658/envelopes/{{envelopeId}}/documents/{{documentId}}');
$request->setRequestMethod('GET');
$request->setOptions(array());
$request->setHeaders(array(
'X-DocuSign-Authentication' => '{"Username":"x@xxx.com","Password":"doOTcFj08wl/xO6uR2ZLX6+rOaE=","IntegratorKey": "xxxx-xxxx-xx-a075-xxx"}',
'Content-Type' => 'application/json'
));
$client->enqueue($request)->send();
$response = $client->getResponse();
echo $response->getBody();
If you echo/debug this string 'https://demo.docusign.net/restapi/v2.1/accounts/7808658/envelopes/{{envelopeId}}/documents/{{documentId}}'
Youll notice that you haven't passed the envelopeId or the documentId, instead, u are passed them as text, please pass the envelopeID and documentID and the API should work fine