2018-10-03 12:43

DocuSign - 无法在createEnvelope上设置“已发送”

  • php

I am using Docusign PHP Client and trying to create and envelope and send it as email. With the current SDK, I was getting an error:

INVALID_REQUEST_BODY The request body is missing or improperly formatted. Cannot deserialize the current JSON object (e.g. {"name":"value"}) into type 'API_REST.Models.v2.document[]' because the type requires a JSON array (e.g. [1,2,3]) to deserialize correctly. ◀ To fix this error either change the JSON to a JSON array (e.g. [1,2,3]) or change the deserialized type so that it is a normal .NET type (e.g. not a primitive t ▶ Path 'documents.documentBase64', line 1, position 31.

So I had to edit EnvelopeApi.php (line 2876) json_encode($httpBody) to make it work.

Now that it's working, I receive a response like this, however I can't change status created to sent is my problem.

EnvelopeSummary {#460 ▼
  #container: array:4 [▼
    "envelope_id" => "6b9ef863-2ee0-4ea6-9f7e-20b7d4f59b22"
    "status" => "created"
    "status_date_time" => "2018-10-03T12:30:22.8600000Z"
    "uri" => "/envelopes/6b9ef863-2ee0-4ea6-9f7e-20b7d4f59b22"

My full code:

First, I authenticated and fetched my $accountId

And then creating Envelope:

$path = public_path('test.pdf');
$b64Doc = base64_encode(file_get_contents($path));

$document = new Document();

$sign_here = new SignHere();

$tabs = new Tabs();

$signers = new Signer();
$signers->setName('Test User');

$recipients = new Recipients();

$envelope_definition = new EnvelopeDefinition();
$envelope_definition->setEmailSubject('Signature Request');
$envelope_definition->setStatus("sent"); // ***

$options = new CreateEnvelopeOptions();

try {
   $envelopeSummary = $envelopeApi->createEnvelope($accountId, $envelope_definition, $options);

   // Also tried this:
   // $envelopeApi->update($accountId, $envelopeSummary->getEnvelopeId(), json_encode(['status' => 'sent']);

 } catch (ApiException $e){
     dd($e->getResponseBody()->errorCode . " " . $e->getResponseBody()->message);

$envelope_definition->setStatus("sent"); this should trigger the email, right? But it doesn't for some reason. Also I can't see this created envelope in my Sandbox either.

  • 点赞
  • 回答
  • 收藏
  • 复制链接分享