0

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();
4
  • Can you update your question to post a full trace of the XML request? (You can easily produce a trace using Fiddler or something similar.) The code you're showing above doesn't show the entire request, so it's difficult to know exactly what's causing the error.
    – Kim Brandl
    Commented Oct 30, 2013 at 14:17
  • Are you saying that sometimes the call succeeds and sometimes it fails when you mention "But sometimes the api call returns 400 bad request"? If that's the case it might actually be an issue with DocuSign's servers and not your code even though you're getting a 400. There were some issues earlier this week where 400 was being returned even though it was a problem with the server, I believe those are resolved now, and production is always more stable than the demo environment...
    – Ergin
    Commented Oct 30, 2013 at 18:37
  • Thanks for your time Kim. I looked over the Fidler trace it shown the error message like "Maximum no.of hourly invocations has been exceeded. The hourly limit is 1000". But I made about 10 to 15 calls consecutively. After that it started to show the "bad request" message. Commented Oct 30, 2013 at 20:10
  • Thanks for your time Ergin. In the past, when uploading the document we got this message rarely because of the upload speed was very low in my internet. For the past 2 to 3 weeks it is been happening. I have also the doubt whether this happen due to "demourl". I don't have the product URL. Commented Oct 30, 2013 at 20:14

2 Answers 2

1

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.

1

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.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.