0
votes

I am making API call in xml format. Using url as http://www.docusign.net/restapi/v2/login_information and production credentials details, I am retrieving accountID and Baseurl then i am trying to Request Envelope Result in xml format which is as below

string requestBody = "http://www.docusign.com/restapi\">" +

            "<accountId>" + accountId + "</accountId>" +

                    "<status>sent</status>" +

                    "<emailSubject>API Call for Embedded Sending</emailSubject>" +

                    "<emailBlurb>This comes from C#</emailBlurb>" +

                    "<templateId>" + templateId + "</templateId>" +

                    "<templateRoles>" +

                    "<templateRole>" +

                    "<email>" + username + "</email>" + // NOTE: Use different email address if username provided in non-email format!

                       "<name>Name</name>" +         // username can be in email format or an actual ID string

                    "<roleName>" + roleName + "</roleName>" +



                    "</templateRole>" +

                    "</templateRoles>" +

                    "</envelopeDefinition>";

then I am making post call

request = (HttpWebRequest)WebRequest.Create(baseURL + "/envelopes");

            request.Headers.Add("X-DocuSign-Authentication", authenticateStr);

            request.ContentType = "application/xml";

            request.Accept = "application/xml";

            request.ContentLength = requestBody.Length;

            request.Method = "POST";

            // write the body of the request

            byte[] body = System.Text.Encoding.UTF8.GetBytes(requestBody);

            Stream dataStream = request.GetRequestStream();

            dataStream.Write(body, 0, requestBody.Length);

            dataStream.Close();

            // read the response

            webResponse = (HttpWebResponse)request.GetResponse();

in the last line, it gives error of 400 bad request.

This works fine with demo account but in production account gives 400 error. Thank you all who try to help me.

1

1 Answers

0
votes

If your code is working in the Demo environment but fails in Production this might be either authentication related or something related to your account settings (in either demo or prod). I suspect it is auth related though.

I see that you are using the older legacy authentication using the /login_information endpoint. When you make the login request in demo the baseUrl is always demo.docusign.net since that's the only sub-domain in that environment.

However for production your account might exist in one of several sub-domains based on where you were when you created the account and a few other factors. I see you using www.docusign.net for your production endpoint which is correct for the Login API but what your integration needs to do is parse the baseUrl that is returned in the response and use THAT as the base for your core API requests.

For example, your production account might reside in one of the following domains:

na2.docusign.net
na3.docusign.net
eu.docusign.net
...

Again to verify which sub-domain your integration should be using for production parse the baseUrl that is returned from the Login API and use that for sub-sequent requests.