asp.net mvc - Getting error while using DocuSign in DotNet application -


i implementing docusign functionality in application sign pdf. following below link: https://www.docusign.com/developer-center/api-overview able add signature in pdf while using steps mentioned in above link while calling same method second time signed new pdf getting error message @ line of createenvelope()

error response: { "errorcode": "unspecified_error", "message": "input string not in correct format." }

it generate error while creating envelop. @ line

envelopesummary envelopesummary = envelopesapi.createenvelope(accountid, envdef);

below code use

static string username = utility.getconfigvalue("docsignusername");         static string password = utility.getconfigvalue("docsignpassword");         static string integratorkey = utility.getconfigvalue("docsignintegratorkey");         static string baseurl = "";          public static signedpdf signdocument(userviewmodel user, stateviewmodel state, string signfilepath, string newfilepath, string controlsign)         {             pdfreader pdfreader = new pdfreader(signfilepath);             pdfreader newpdfreader = new pdfreader(newfilepath);             pdfstamper pdfstamper = new pdfstamper(newpdfreader, new filestream(httpcontext.current.server.mappath(utility.getconfigvalue("statetaxforms")) + "test.pdf", filemode.create));             acrofields pdfformfields = pdfstamper.acrofields;             ilist<acrofields.fieldposition> fieldpositions = pdfformfields.getfieldpositions(controlsign);              try             {                 acrofields.fieldposition fieldposition = fieldpositions[0];                  // enter recipient (signer) name , email address                 string recipientname = user.firstname + " " + user.lastname;                 string recipientemail = user.email;                  // instantiate api client appropriate environment (for production change www.docusign.net/restapi)                 string basepath = utility.getconfigvalue("docsigninstantiateclient");                  // instantiate new api client                 apiclient apiclient = new apiclient(basepath);                  // set client in global config don't need pass each api object                 configuration.default.apiclient = apiclient;                  string authheader = "{\"username\":\"" + username + "\", \"password\":\"" + password + "\", \"integratorkey\":\"" + integratorkey + "\"}";                 configuration.default.adddefaultheader("x-docusign-authentication", authheader);                  // retrieve login() results                 string accountid = null;                  // authentication api uses apiclient (and x-docusign-authentication header) set in configuration object                 authenticationapi authapi = new authenticationapi();                 logininformation logininfo = authapi.login();                  // user might member of multiple accounts                 accountid = logininfo.loginaccounts[0].accountid;                  // read file disk use document                 byte[] filebytes = file.readallbytes(signfilepath);                  envelopedefinition envdef = new envelopedefinition();                 envdef.emailsubject = "please sign document";                  // add document envelope                 document doc = new document();                 doc.documentbase64 = system.convert.tobase64string(filebytes);                 doc.name = "signedfile.pdf";                 doc.documentid = "1";                  envdef.documents = new list<document>();                 envdef.documents.add(doc);                  // add recipient sign documeent                 signer signer = new signer();                 signer.name = recipientname;                 signer.email = recipientemail;                 signer.recipientid = "1";                  // must set |clientuserid| embed recipient                 signer.clientuserid = "1234";                  // create |signhere| tab somewhere on document recipient sign                 signer.tabs = new tabs();                 signer.tabs.signheretabs = new list<signhere>();                 signhere signhere = new signhere();                  var height = pdfreader.getpagesize(1).height;                 signhere.documentid = "1";                 signhere.recipientid = "1";                 signhere.pagenumber = convert.toint32(fieldposition.page).tostring();                 signhere.xposition = convert.toint32(fieldposition.position.left).tostring();                 if (state.abbreviation == "dc" && controlsign != "signature of employee")                 {                     signhere.yposition = (height - convert.toint32(fieldposition.position.top - 5)).tostring();                 }                 else                 {                     signhere.yposition = (height - convert.toint32(fieldposition.position.top + 35)).tostring();                 }                 if (state.abbreviation == "nc" && controlsign != "signature of employee")                 {                     signhere.yposition = (height - convert.toint32(fieldposition.position.top + 25)).tostring();                 }                 signer.tabs.signheretabs.add(signhere);                  envdef.recipients = new recipients();                 envdef.recipients.signers = new list<signer>();                 envdef.recipients.signers.add(signer);                  // set envelope status "sent" send signature request                 envdef.status = "sent";                  // use envelopesapi create , send signature request                 envelopesapi envelopesapi = new envelopesapi();                 envelopesummary envelopesummary = envelopesapi.createenvelope(accountid, envdef);                  recipientviewrequest viewoptions = new recipientviewrequest()                 {                     returnurl = utility.getconfigvalue("docsignreturnurl"),                     clientuserid = "1234",  // must match clientuserid set in step #2!                     authenticationmethod = "email",                     username = recipientname,                     email = recipientemail                 };                  // create recipient view (aka signing url)                 viewurl recipientview = envelopesapi.createrecipientview(accountid, envelopesummary.envelopeid, viewoptions);                  // start embedded signing session!                 //var value = system.diagnostics.process.start(recipientview.url);                 signedpdf signedpdf = new signedpdf();                 signedpdf.url = recipientview.url;                 signedpdf.envelopeid = envelopesummary.envelopeid;                 return signedpdf;             }             catch (exception ex)             {                 throw new pdfsignexception(errorconstants.there_was_an_error_while_signing_pdf);             }                         {                 pdfstamper.close();                 pdfreader.close();             }         } 

hi codingdawg json

{   "documents": [     {       "documentbase64": "",       "documentid": "1",       "name": "signedfile.pdf"     }   ],   "emailsubject": "please sign document",   "recipients": {     "signers": [       {         "clientuserid": "1234",         "email": "sagar.mali@tudip.com",         "name": "sagar mali",         "recipientid": "1",         "tabs": {           "signheretabs": [             {               "documentid": "1",               "pagenumber": "1",               "recipientid": "1",               "xposition": "192",               "yposition": "679.968"             }           ]         }       }     ]   },   "status": "sent" } 

we have removed base 64 string length not supporting.

make sure signhere.xposition & signhere.yposition values passed correctly.

the following statement evaluate decimal value. make sure integer.

signhere.yposition = (height - convert.toint32(fieldposition.position.top + 25)).tostring(); 

troubleshooting step

please run envelopedefinition.tojson() (sdk documentation) , make sure final json posted docusign api correct.


Comments

Popular posts from this blog

networking - Vagrant-provisioned VirtualBox VM is not reachable from Ubuntu host -

c# - ASP.NET Core - There is already an object named 'AspNetRoles' in the database -

ruby on rails - ArgumentError: Missing host to link to! Please provide the :host parameter, set default_url_options[:host], or set :only_path to true -