Tagged: 

This topic contains 26 replies, has 2 voices, and was last updated by  chaudboy 13 hours, 25 minutes ago.

  • Author
    Posts
  • Participant
    chaudboy
    Member
    Member since: 03.07.2017
    Number of posts: 14

    Hello,

    i’m a junior developer and it has been my second week learning Node JS so errors might be because of my poor use of Javascript.

    My problem is that after sending a request pretty much like in the example given on this link i get an undefined package id.

    I suppose this is caused by un unvalid json payload or options objet. Here is my code.
    The build of the json payload is done at line 23. I changed some of the values to make it look more like our webapp but since your example is quite basic i don’t know if this is the problem ..
    The http request to your API is done at line 234.

    Thank you for your time.

    Keymaster
    harishaidary
    Guru
    Member since: 05.11.2015
    Number of posts: 817

    Score

    0

    Hi there,

    Looking at your JSON payload, can you remove the single quotation marks around where you put your own information? In other words, can you use the following payload and see if it resolves the issue?

    {
      "roles": [
        {
          "id": "Signer1",
          "type": "SIGNER",
          "signers": [
            {
              "firstName": "lionel",
              "lastName": "jamaigne",
              "email": "lionel.jam@docunify.com",
              "id": "Signer1"
            }
          ]
        },
        {
          "id": "Sender1",
          "type": "SIGNER",
          "signers": [
            {
              "firstName": "Haris",
              "lastName": "Haidary",
              "email": "sender@example.com",
              "id": "Sender1"
            }
          ]
        }
      ],
      "documents": [
        {
          "fields": [
            {
              "value": "lionel",
              "name": "first_name"
            },
            {
              "value": "jamaigne",
              "name": "last_name"
            },
            {
              "value": "rue du truc",
              "name": "address"
            },
            {
              "value": "martelange",
              "name": "city"
            },
            {
              "value": "8832",
              "name": "zip"
            },
            {
              "value": "saipas",
              "name": "state"
            },
            {
              "value": "belgique",
              "name": "country"
            },
            {
              "value": "32499463127",
              "name": "phone_number"
            },
            {
              "value": "lionel.jamaigne@docunify.com",
              "name": "email"
            },
            {
              "value": "docunify sa",
              "name": "company"
            },
            {
              "value": "44",
              "name": "policy_number"
            }
          ],
          "name": "Sample Contract",
          "id": "contract",
          "extract": true
        }
      ],
      "name": "NodeJS Example",
      "type": "PACKAGE",
      "status": "DRAFT"
    }

    I was able to successfully create a package with the above payload. Also, make sure that you are using the same document I provided in my blog as the payload above is setup for the Document Extraction and Field Injection features.


    Haris Haidary
    eSignLive Technical Evangelist
    Keymaster
    harishaidary
    Guru
    Member since: 05.11.2015
    Number of posts: 817

    Score

    0

    Btw, here’s the node.js code I used to create the package:

    var fs = require("fs");
    var request = require("request");
    
    var options = { method: 'POST',
      url: 'https://sandbox.esignlive.com/api/packages',
      headers: 
       { 
         accept: 'application/json; esl-api-version=11.0',
         authorization: 'Basic api_key',
         'content-type': 'multipart/form-data; boundary=----WebKitFormBoundary7MA4YWxkTrZu0gW' },
      formData: 
       { payload: '{"roles":[{"id":"Signer1","type":"SIGNER","signers":[{"firstName":"lionel","lastName":"jamaigne","email":"lionel.jam@docunify.com","id":"Signer1"}]},{"id":"Sender1","type":"SIGNER","signers":[{"firstName":"Haris","lastName":"Haidary","email":"sender@example.com","id":"Sender1"}]}],"documents":[{"fields":[{"value":"lionel","name":"first_name"},{"value":"jamaigne","name":"last_name"},{"value":"rue du truc","name":"address"},{"value":"martelange","name":"city"},{"value":"8832","name":"zip"},{"value":"saipas","name":"state"},{"value":"belgique","name":"country"},{"value":"32499463127","name":"phone_number"},{"value":"lionel.jamaigne@docunify.com","name":"email"},{"value":"docunify sa","name":"company"},{"value":"44","name":"policy_number"}],"name":"Sample Contract","id":"contract","extract":true}],"name":"NodeJS Example","type":"PACKAGE","status":"DRAFT"}',
         file: 
          { value: 'fs.createReadStream("C:/Users/hhaidary/Desktop/pdfs/doc1.pdf")',
            options: { filename: 'doc1.pdf', contentType: null } } } };
    
    request(options, function (error, response, body) {
      if (error) throw new Error(error);
    
      console.log(body);
    });

    Haris Haidary
    eSignLive Technical Evangelist
    • This reply was modified 6 days, 17 hours ago by  harishaidary.
    Participant
    chaudboy
    Member
    Member since: 03.07.2017
    Number of posts: 14

    Score

    0

    Hi,

    Thank you for such a fast answer.
    Do i have to send the payload as a string or as an object ? I don’t understand why you have to use ‘+’ to build the payload as a string if you cant use an object & just set the values with the form.

    Have a good afternoon.

    Keymaster
    harishaidary
    Guru
    Member since: 05.11.2015
    Number of posts: 817
    Approved answer

    Score

    0

    You can build the payload as a string or an object. However, when making the request to esignlive, you’ll have to send the payload as a string, as shown above.


    Haris Haidary
    eSignLive Technical Evangelist
    Participant
    chaudboy
    Member
    Member since: 03.07.2017
    Number of posts: 14

    Score

    0

    Hello,

    Thank you for your help it was very helpful. Another error that i detected was my ‘content-type’ parameter which was set to ‘null’ instead of null.

    Unfortunately, i also have a problem with the session token. I embedded the token request in the handler of the package id request here in line 323.

    My session token is undefined & the body empty.

    Am i doing things correctly ?

    Again, thank you for your time.

    Keymaster
    harishaidary
    Guru
    Member since: 05.11.2015
    Number of posts: 817

    Score

    0

    Hey there,

    Is your package is SENT status? It is a requirement for retrieving a signer authentication token. In your json payload, change “status” to “SENT”. I put it to draft simply because I didn’t want to spam your email inbox 🙂 Let me know.


    Haris Haidary
    eSignLive Technical Evangelist
    • This reply was modified 3 days, 17 hours ago by  harishaidary.
    • This reply was modified 3 days, 17 hours ago by  harishaidary.
    Participant
    chaudboy
    Member
    Member since: 03.07.2017
    Number of posts: 14

    Score

    0

    Hi,

    Not only i still can’t get the session token but now i don’t get the package id either. Just by changing DRAFT to SENT they both are undefined. Are you sure these types of requests can be done with a sandbox account ?

    Have a good afternoon 🙂

    Keymaster
    harishaidary
    Guru
    Member since: 05.11.2015
    Number of posts: 817

    Score

    0

    Are you sure you are using the same document I provided? Like I mentioned in my previous post, the payload in my node.js example was setup to automatically extract the positions of the signatures from the pdf document. If you are using another document, then you will not be able to send the package for signing, as there won’t be any signatures placed on the document. How about you try the following payload:

    {
      "documents": [
        {
          "approvals": [
            {
              "id": "ExampleSignatureId",
              "role": "Signer1",
              "fields": [
                {
                  "page": 0,
                  "top": 200,
                  "subtype": "LABEL",
                  "height": 50,
                  "binding": "{approval.signed}",
                  "left": 100,
                  "width": 200,
                  "id": "myLabelField",
                  "type": "INPUT",
                  "value": "dd/mm/yyyy"
                },
                {
                  "page": 0,
                  "top": 100,
                  "subtype": "FULLNAME",
                  "height": 50,
                  "left": 100,
                  "width": 200,
                  "type": "SIGNATURE",
                  "name": "ExampleSignatureId"
                }
              ],
              "name": ""
            }
          ],
          "id": "sample-contract",
          "name": "Test Document"
        }
      ],
      "status": "SENT",
      "type": "PACKAGE",
      "roles": [
        {
          "id": "Signer1",
          "type": "SIGNER",
          "signers": [
            {
              "email": "mail32@mailinator.com",
              "firstName": "John",
              "lastName": "Smith",
              "id": "Signer1"
            }
          ],
          "name": "Signer1"
        }
      ],
      "name": "Example Package"
    }

    Haris Haidary
    eSignLive Technical Evangelist
    Participant
    chaudboy
    Member
    Member since: 03.07.2017
    Number of posts: 14

    Score

    0

    Hello Mr Haidary,

    You are right i forgot about the fact that the code was set to this actual document. The retrieval of the packageid and the session token run smoothly thanks to your payload & advices.

    However, when i get the iframe in our front-end, i have this result as shown in the attachment. What can i understand from it ?

    Thank you++;

    Attachments:
    You must be logged in to view attached files.
    Participant
    chaudboy
    Member
    Member since: 03.07.2017
    Number of posts: 14

    Score

    0

    After noticing an error on the building of the url, i getanother error from your servers which is attached to this message.

    Attachments:
    You must be logged in to view attached files.
    Keymaster
    harishaidary
    Guru
    Member since: 05.11.2015
    Number of posts: 817

    Score

    0

    What is the url you are embedding in the iframe?


    Haris Haidary
    eSignLive Technical Evangelist
    Participant
    chaudboy
    Member
    Member since: 03.07.2017
    Number of posts: 14
    Keymaster
    harishaidary
    Guru
    Member since: 05.11.2015
    Number of posts: 817

    Score

    0

    I see. The URL you are trying to embed is for the designer, which requires a user authentication token and the package status being in draft. The designer is when you want to give your users access to the package and the freedom to place the signatures/fields on the documents. If you want to create a signing session, then you will need to embed the following URL using the signer authentication token:

    https://sandbox.esignlive.com/access?sessionToken={signerAuthenticationToken}


    Haris Haidary
    eSignLive Technical Evangelist
    • This reply was modified 2 days, 17 hours ago by  harishaidary.
    Participant
    chaudboy
    Member
    Member since: 03.07.2017
    Number of posts: 14

    Score

    0

    What we would like to do is to have a specific area for each users signing. What i’m doing now is provide an iframe based off the document they picked on our websites & then chose per signer a specific area. Will i be able to do this with your provided URL ?

You must be logged in to reply to this topic.