CoolestUsername
CoolestUsername

Reputation: 195

Creating an envelope from a template returning "UNSPECIFIED_ERROR"

When I try to create an envelope from a template I get a response of:

{ errorCode: 'UNSPECIFIED_ERROR',
  message: 'Non-static method requires a target.' }

Here's what I'm doing so far:

First I login, which returns

 { loginAccounts: 
   [ { name: '*****',
       accountId: '*****',
       baseUrl: 'https://demo.docusign.net/restapi/v2/accounts/******',
       isDefault: 'true',
       userName: '***** ********',
       userId: '*******-*****-*****-*****-*********',
       email: '********@*******.com',
       siteDescription: '' } ] }

So then I take the baseUrl out of that response and I attempt to create the envelope. I'm using the hapi framework and async.waterfall of the async library, so for anyone unfamiliar with either of these my use of the async library uses the next callback to call the next function which in this case would be to get the url for the iframe, and with our usage of the hapi framework AppServer.Wreck is roughy equivalent to request:

    function prepareEnvelope(baseUrl, next) {
        var createEntitlementTemplateId = "99C44F50-2C97-4074-896B-2454969CAEF7";
        var getEnvelopeUrl  = baseUrl + "/envelopes";
        var options = {
            headers: {
                "X-DocuSign-Authentication": JSON.stringify(authHeader),
                "Content-Type": "application/json",
                "Accept": "application/json",
                "Content-Disposition": "form-data"
            },
            body : JSON.stringify({
                status: "sent",
                emailSubject: "Test email subject",
                emailBlurb: "My email blurb",
                templateId: createEntitlementTemplateId,
                templateRoles: [
                    {
                        email: "[email protected]",
                        name: "Recipient Name",
                        roleName: "Signer1",
                        clientUserId: "1099", // TODO: replace with the user's id
                        tabs : {
                            textTabs : [
                                {
                                     tabLabel : "acct_nmbr",
                                     value : "123456"
                                },
                                {
                                    tabLabel : "hm_phn_nmbr",
                                    value : "8005882300"
                                },
                                {
                                    tabLabel : "nm",
                                    value : "Mr Foo Bar"
                                }
                            ]
                        }
                    }
                ]
            })
        };

        console.log("--------> options: ", options); // REMOVE THIS ====

        AppServer.Wreck.post(getEnvelopeUrl, options, function(err, res, body) {
            console.log("Request Envelope Result: \r\n", JSON.parse(body));
            next(null, body, baseUrl);
        });
    }

And what I get back is:

 { errorCode: 'UNSPECIFIED_ERROR',
  message: 'Non-static method requires a target.' }

From a little googling it look like 'Non-static method requires a target.' is a C# error and doesn't really give me much indication of what part of my configuration object is wrong.

I've tried a simpler version of this call stripping out all of the tabs and clientUserId and I get the same response.

I created my template on the Docusign website and I haven't ruled out that something is set up incorrectly there. I created a template, confirmed that Docusign noticed the named form fields, and created a 'placeholder' templateRole.

Here's the templateRole placeholder: placeholder templateRole

Here's one of the named fields that I want to populate and corresponding data label: named form fields

As a side note, I was able to get the basic vanilla example working without named fields nor using a template using the docusign node package just fine but I didn't see any way to use tabs with named form fields with the library and decided that I'd rather have more fine-grained control over what I'm doing anyway and so I opted for just hitting the APIs.

Surprisingly when I search SO for the errorCode and message I'm getting I could only find one post without a resolution :/

Of course any help will be greatly appreciated. Please don't hesitate to let me know if you need any additional information.

Upvotes: 0

Views: 425

Answers (1)

CoolestUsername
CoolestUsername

Reputation: 195

Once I received feedback from Docusign that my api call had an empty body it didn't take but a couple minutes for me to realize that the issue was my options object containing a body property rather than a payload property, as is done in the hapi framework.

Upvotes: 5

Related Questions