Question

I tried with Timeout properties for uploading document in Docusign through demo url from API. But sometimes the api call returns "The remote server returned an error: (400) Bad Request". I looked into the fiddler debug trace. The XML shows 2 things are errorcode and message "1. errorCode : HOURLY_APIINVOCATION_LIMIT_EXCEEDED. 2. Message : The Maximum no of hourly API Invocations has been exceeded. The hourly limit is 1000".. But it was about only 15 to 20 calls I can continuously upload. After that the bad request will start. Again it starting to upload after some time. I cannot upload the Fidler XML image. It shown it need 10 reputations to post image.

string envdef = "<envelopeDefinition xmlns=\"http://www.docusign.com/restapi\">" + envDef;
string temp = Environment.ExpandEnvironmentVariables("%temp%");
FileStream fileStream = System.IO.File.OpenRead(path);

// build the multipart request body
string requestBodyStart = "\r\n\r\n--BOUNDARY\r\n" +
    "Content-Type: application/xml\r\n" +
    "Content-Disposition: form-data\r\n" +
        "\r\n" +
        envdef + "\r\n\r\n--BOUNDARY\r\n" + // our xml formatted envelopeDefinition
    "Content-Type: application/x-www-form-urlencoded\r\n" +
    "Content-Disposition: file; filename=\"CaptionBookmarkTest - 214744463.doc\"; documentId=1\r\n" +
    "\r\n";

string requestBodyEnd = "\r\n--BOUNDARY--\r\n\r\n";
// use baseURL value + "/envelopes" for url of this request
request.Timeout = 1000000;

request = (HttpWebRequest)WebRequest.Create(baseURL + "/envelopes");
request.Headers.Add("X-DocuSign-Authentication", authenticateStr);
request.ContentType = "multipart/form-data; boundary=BOUNDARY";
request.Accept = "application/xml";
request.ContentLength = requestBodyStart.ToString().Length + fileStream.Length + requestBodyEnd.ToString().Length;
request.Method = "POST";

// write the body of the request
byte[] bodyStart = System.Text.Encoding.UTF8.GetBytes(requestBodyStart.ToString());
byte[] bodyEnd = System.Text.Encoding.UTF8.GetBytes(requestBodyEnd.ToString());
Stream dataStream = request.GetRequestStream();
dataStream.Write(bodyStart, 0, requestBodyStart.ToString().Length);

// Read the file contents and write them to the request stream
byte[] buf = new byte[4096];
int len;
while ((len = fileStream.Read(buf, 0, 4096)) > 0)
{
    dataStream.Write(buf, 0, len);
}
dataStream.Write(bodyEnd, 0, requestBodyEnd.ToString().Length);
dataStream.Close();

// read the response
request.MaximumAutomaticRedirections = 4;
webResponse = (HttpWebResponse)request.GetResponse();
sr.Close();
responseText = "";
sr = new StreamReader(webResponse.GetResponseStream());
responseText = sr.ReadToEnd();
StreamWriter SW;
SW = System.IO.File.CreateText(temp + "\\upload.XML");
SW.WriteLine(responseText);
SW.Close();
sr.Close();
Was it helpful?

Solution

DocuSign has api call limits in place - you are limited to 1000 api calls per account per hour. It looks like you are hitting this limit, which is rare so I would be curious as to how and why you are making that many calls in less than 1 hour.

The hour window is not a sliding window but rather it's from the top of each hour to the start of the next. So for instance, you can not make more than 1000 api calls in a given account between 3pm and 4pm.

Please note that this is not just for signature request api calls, but ANY api call you make against DocuSign's servers. So if you make the Login api call to retrieve your baseUrl and accountId, then that counts as one call. Then if you use that baseUrl for a subsequent signature request or other api call, that counts as 2, and so on.

OTHER TIPS

Docusign is attempting to contact your website, but has been failing over 1000 times for the hour, thereby reaching their limit. To resolve, restart your site's app pool, and retest or check the error logs again after the new hour starts. If still an issue after that, check your latest web code for errors.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top