1

I have a concern regarding DocuSign, that i can't manage to resolve, Hope that someone could give me a hint or spot what I'm missing.

Currently in the application , a user can select a document to sign, so when i try to implement the signing part with DocuSign i got this error "404 : "NO_DOCUMENT_RECEIVED": "The document element did not contain the encoded document, 'documentId='possibly missing from Content-Disposition header." ".

here a bunch of code that i'm working on it for the moment i have implemented two kind of solution, one is working and the other one not :

Not working : $args["doccontent"] is the way i call the document from database(its a pdf).

                                        
      
   $doc_internal_name = str_replace("http://127.0.0.1:8000/","C:/laragon2/www/ApplicationNAme/public/",$args['doccontent']); 
    
    $doc_content = file_get_contents($doc_internal_name );
   
    $base64FileContent = base64_encode($doc_content);
 
    $document = new Document(
        [
            'document_base64' => $base64FileContent,
            'name' => 'testdoc',
            'file_extension' => "pdf",
            'document_id' => 1
        ]
    );
  
      
        /* Create the signer recipient model */
   

        $signer = new \DocuSign\eSign\Model\Signer([
            'email' => email,  
            'name' => name , 
            'recipient_id' => '1', 
            'routing_order' => '1',
            'client_user_id' => $args['signer_client_id']
        ]);
  
        /* Create a signHere tab (field on the document) */
        $signHere = new \DocuSign\eSign\Model\SignHere([
            'anchor_string' => '/sn1/', 
            'anchor_units' => 'pixels',
            'anchor_y_offset' => '10', 
            'anchor_x_offset' => '20'
        ]);
  
        /* Create a signHere 2 tab (field on the document) */
        $signHere2 = new \DocuSign\eSign\Model\SignHere([
            'anchor_string' => '/sn2/', 
            'anchor_units' => 'pixels',
            'anchor_y_offset' => '40', 
            'anchor_x_offset' => '40'
        ]);
         
        $signer->settabs(new \DocuSign\eSign\Model\Tabs(['sign_here_tabs' => [$signHere, $signHere2]]));
 
        $envelopeDefinition  = new \DocuSign\eSign\Model\EnvelopeDefinition([
            'email_subject' => "Please sign this document",
            'documents' => [$document],
            'recipients' => new \DocuSign\eSign\Model\Recipients(['signers' => [$signer]]),
           
           
        ]);
       
       
        return $envelopeDefinition;


Working : when i specify directly the same path of the same document in the solution that is not working :

 $content = file_get_contents("../public/uploads/zbD0nVz3NoEYjg2ttHnrhoJ7JM7OQbqSVQCnNT8U.pdf");
 $base64FileContent = base64_encode($content);
    $document = new Document(
        [
            'document_base64' => $base64FileContent,
            'name' => 'test',
            'file_extension' => 'pdf',
            'document_id' => 1
        ]
    );
     /* Create the signer recipient model */
   

        $signer = new \DocuSign\eSign\Model\Signer([
            'email' => email,  
            'name' => name , 
            'recipient_id' => '1', 
            'routing_order' => '1',
            'client_user_id' => $args['signer_client_id']
        ]);
  
        /* Create a signHere tab (field on the document) */
        $signHere = new \DocuSign\eSign\Model\SignHere([
            'anchor_string' => '/sn1/', 
            'anchor_units' => 'pixels',
            'anchor_y_offset' => '10', 
            'anchor_x_offset' => '20'
        ]);
  
        /* Create a signHere 2 tab (field on the document) */
        $signHere2 = new \DocuSign\eSign\Model\SignHere([
            'anchor_string' => '/sn2/', 
            'anchor_units' => 'pixels',
            'anchor_y_offset' => '40', 
            'anchor_x_offset' => '40'
        ]);
         
        $signer->settabs(new \DocuSign\eSign\Model\Tabs(['sign_here_tabs' => [$signHere, $signHere2]]));
 
        $envelopeDefinition  = new \DocuSign\eSign\Model\EnvelopeDefinition([
            'email_subject' => "Please sign this document",
            'documents' => [$document],
            'recipients' => new \DocuSign\eSign\Model\Recipients(['signers' => [$signer]]),
           
           
        ]);
       
       
        return $envelopeDefinition;

but i want the first one to work, cause different users will use the application and they will be signing different document

thank you so much for your help.

  • Can you show us one example of this `$args["doccontent"]` ? – Maraboc Aug 22 '23 at 15:24
  • thank for your replay : when i dump $doc_internal_name here's what i got "../public/uploads/zbD0nVz3NoEYjg2ttHnrhoJ7JM7OQbqSVQCnNT8U.pdf" is that what you want to know ? – user16795407 Aug 22 '23 at 15:33
  • In this case try this : in your working code replace this `$content = file_get_contents("../public/uploads/xP7ZKqRBWPcb9aXMqzjP0l8zXt285xHOpYHGRZZf.pdf");` by this `$content = file_get_contents($args["doccontent"]);` – Maraboc Aug 22 '23 at 15:37
  • When i do that i get : Maximum execution time of 60 seconds exceeded. – user16795407 Aug 22 '23 at 15:46
  • I think it's another error related to the size of data that you have, but the first proposition will work – Maraboc Aug 22 '23 at 15:48
  • ok i will try to check on the size of the data, but it's the same doc for both method, that's what i don't understand, it's just the way i call it that it's different. thank again for your help – user16795407 Aug 22 '23 at 16:43

1 Answers1

0

This issue is not directly related to the DocuSign APIs. When you send bytes to the API - you have to make sure there are actual bytes of a file that you're sending. Your code has an issue getting these bytes - so the API is returning the correct error that no bytes were received for the document.

Make sure that the first version of the code has the correct URL for the PDF you want to read and it will work.

Inbar Gazit
  • 12,566
  • 1
  • 16
  • 23
  • Thanks for your replay, but what i don't understand is that the url is the same for both version, it's just that that in the second version a write it bold in the code and in the first version am using a value . the dump of $doc_internal_name is "../public/uploads/zbD0nVz3NoEYjg2ttHnrhoJ7JM7OQbqSVQCnNT8U.pdf it's the same one that i use in the second version – user16795407 Aug 23 '23 at 08:06
  • can you please, give me a hint or what i should do to fix this issues. Thank you in advance – user16795407 Aug 23 '23 at 14:39
  • debug your code, see what is the value of $args["doccontent"] – Inbar Gazit Aug 23 '23 at 15:09
  • see what is the value of $doc_internal_name and also most importantly the value of $base64FileContent – Inbar Gazit Aug 23 '23 at 15:10
  • On debug mode : value of $args["doccontent"] : 127.0.0.1:8000/uploads/XSCabXEMXyg2ULin8Z2c39wIeLeTdyqI0kkLrlZM.pdf the value of $doc_internal_name : C:/laragon/www/ApplicationName/public/uploads/XSCabXEMXyg2ULin8Z2c39wIeLeTdyqI0kkLrlZM.pdf Value of $base64FileContent : "JVBERi0xLjMKJcTl8uXrp/Og0MTGCjQgMCBvYmoKPDwgL0xlbmd0aCA1IDAgUiAvRm... – user16795407 Aug 23 '23 at 15:35
  • ok, what about the rest of your code? is it the same in both cases? because you do have your working code somewhere – Inbar Gazit Aug 23 '23 at 15:45
  • Sorry i didn't understand you can you please specify ? – user16795407 Aug 23 '23 at 15:48
  • for the version 1 of the code i can't sign but with the version 2 i can sign and be redirected to the application – user16795407 Aug 23 '23 at 15:49
  • Yes, but this is not the full code. Can you post version 1 and 2 the entire code you are writing to make the API call to sign – Inbar Gazit Aug 23 '23 at 15:52
  • i've added the complete code of this function for both version in the main post. it's the same it's only the way i call the value of document that change. thank you so much for reply and patience – user16795407 Aug 23 '23 at 16:01
  • There's something that is not correct, I can't know what it is, but triple check everything. What you can also do is copy the few lines from version 2 to version 1, so that both of these run one after the other and see if it works – Inbar Gazit Aug 23 '23 at 16:15
  • Another approach, is to hardcode the base64 value you wrote earlier in the code of version 1 and see if that works – Inbar Gazit Aug 23 '23 at 16:15
  • basically start line by line debugging and starting with code that works, adding 1 line, see if it still works, adding another line until it breaks and see why – Inbar Gazit Aug 23 '23 at 16:16
  • ok i will do that , i already hardcoded the value of base64 in version 1 and it's work, it's only working when the value is hardcoded, if not i got the error. thanks again – user16795407 Aug 23 '23 at 16:20
  • So, let me understand this You have a variable X, the value if that variable is Y If you put X - doesn't work If you put Y - works? That is logic contradiction, you need to quadruple check everything, this cannot be, it's a basic concept of computer science, if a variable value is Y, you can put Y or this variable and must get the same result – Inbar Gazit Aug 23 '23 at 16:23
  • the variable X has value X1 i got it from database , when i tried to use it in version1 i got this error so i took the value X1 and hardcoded directly in my code that is version2 and it's work perfectly. – user16795407 Aug 23 '23 at 16:32
  • Then your issue is getting the value from the database, not sure how you do that – Inbar Gazit Aug 23 '23 at 16:32
  • i will check the value coming from database. thankyou – user16795407 Aug 23 '23 at 16:42