asp.net mvc - Docusign Embedded Signing(MVC website) - tags not showing up and the document is coming as free form signing -
i trying integrate website docusign via embedded signing. have been pretty successful - documentation , pointers so).
my issue have website , on initial sign need users e-sign document before proceed shop @ site. have set docusign embedded signing experience once login - take them seamlessly(without login docusign server etc) docusign - in document signing shows - document coming thru fine - tags not showing , showing free form signing. there "fields" left of document , need drag , drop these on form ( have populated these fields values).
the real issue docusign lets me "finish" without signing since document showing free form - please find code below - using docusign rest api created embedded signing predefined document template using /envelopes/{envelopeid}/views/recipient call. using restsharp connect docusign. help!
protected const string integratorkey = "xx"; protected const string environment = "https://demo.docusign.net"; protected const string templaterole = "applicant"; protected const string templateid = "xx"; private static logger logger = logmanager.getcurrentclasslogger(); protected const string accountemail = "xx@xx.com"; protected const string accountpassword = "***"; private restsharp.restclient client = new restclient(); private restsharp.restrequest request; bool docusigncallresult = false; // // get: /docusign/ public actionresult launchdocusign(int id) { restsettings.instance.integratorkey = integratorkey; restsettings.instance.docusignaddress = environment; restsettings.instance.webserviceurl = environment + "/restapi/v2"; domain.account currentaccount = null; using (var accountrepo = new accountrepository()) { currentaccount = accountrepo.accountget(id); } string recipientemail = currentaccount.email; string recipientname = currentaccount.fullname; account docusignacct = getdocusignacctdetails(); envelope docusignenvelope = getdocusignenvelopedetails(docusignacct,recipientemail,recipientname); recipientview rv = getrecipientview(recipientemail, recipientname); client = new restsharp.restclient(environment); request = new restrequest("/restapi/{apiversion}/accounts/{accountid}/envelopes/{envelopeid}/views/recipient"); request.addurlsegment("apiversion", "v2"); request.addurlsegment("accountid", docusignacct.accountid); request.addurlsegment("envelopeid", docusignenvelope.envelopeid); mysite.web.models.docusigndata.authenticationheader header = new mysite.web.models.docusigndata.authenticationheader(); var jsonheader = jsonconvert.serializeobject(header); request.addheader("x-docusign-authentication", jsonheader); request.method = method.post; request.requestformat = dataformat.json; request.addjsonbody(rv); var response = client.execute(request); char[] charstotrim = { '\r', '\n', ' ', '\'' }; var json = response.content.trim(charstotrim); var jo = jobject.parse(json); var recipienturl = jo["url"].tostring(); return redirect(recipienturl); } /// <summary> /// recipient view launch docusign(embedded signing experience) /// </summary> /// <param name="recipientemail"></param> /// <param name="recipientname"></param> /// <returns></returns> private recipientview getrecipientview(string recipientemail, string recipientname) { recipientview rv = new recipientview(); rv.authenticationmethod = "email"; rv.returnurl = request.url.scheme + system.uri.schemedelimiter + request.url.host + "/mysitecontroller/mysiteactionmethod"; rv.email = recipientemail; rv.username = recipientname; rv.clientuserid = "1"; return rv; } /// <summary> /// create envelope using template on docusign /// </summary> /// <param name="acct"></param> /// <param name="recipientemail"></param> /// <param name="recipientname"></param> /// <returns></returns> private envelope getdocusignenvelopedetails(account acct,string recipientemail,string recipientname) { envelope envelope = new envelope(); envelope.login = acct; envelope.status = "sent"; envelope.emailsubject = "testing"; envelope.templateid = templateid; envelope.templateroles = new templaterole[] { new templaterole() { email = recipientemail, name = recipientname, rolename = templaterole, clientuserid = "1" } }; try { docusigncallresult = envelope.create(); } catch (exception ex) { logger.error("login docusign failed due {0} , exception generated {2}", envelope.resterror.message, ex.message); } return envelope; } /// <summary> /// access docusign account information /// </summary> /// <returns></returns> private account getdocusignacctdetails() { account docusignacct = new account(); docusignacct.email = accountemail; docusignacct.password = accountpassword; try { docusigncallresult = docusignacct.login(); } catch (exception ex) { logger.error("login docusign failed due {0} , exception generated {2}", docusignacct.resterror.message, ex.message); } return docusignacct; } }
}
as jeff has mentioned in comments caused not matching recipient correctly template (placeholder) role on template. code looks sending value applicant
template role name - means need have role called applicant
in template in web console.
for instance, in below screenshot role name signer1
:
to fix either login console , name role on template "applicant" or whatever name has copy code , send in api request.
Comments
Post a Comment