This is an archived forum post. The information may be outdated. Contact us if you have any questions.

(C#) Pdfcrowd Error: 503 - Simultaneous API calls from a single IP are not allowed

tuanpa wrote on 2013-10-18:
I have just setup the URI to PDF API for ASP.Net-C# and it is most excellent. However, I am getting a 503 error, Simultaneous API calls from a single IP are not allowed. I don't want to be sending simultanious calls, just one. Could you look at the code below and tell me what I am doing wrong?
link URL: http://toannn.no-ip.biz/admin/admin.export

string getURL = "http://toannn.no-ip.biz/admin/admin.export";
string strfileName = "report";
System.Web.HttpResponse Response = System.Web.HttpContext.Current.Response;
try
{
// create an API client instance
pdfcrowd.Client client = new pdfcrowd.Client("xxx", "xxx");

// convert a web page and write the generated PDF to a memory stream
MemoryStream mstream = new MemoryStream();
client.convertURI(getURL, mstream);
// set HTTP response headers

Response.Clear();
Response.AddHeader("Content-Type", "application/pdf");
Response.AddHeader("Cache-Control", "no-cache");
Response.AddHeader("Accept-Ranges", "none");
Response.AddHeader("Content-Disposition", "attachment; filename=" + strfileName + ".pdf");
// send the generated PDF
mstream.WriteTo(Response.OutputStream);
mstream.Close();
Response.Flush();
Response.End();
}
catch (pdfcrowd.Error why)
{
Response.Write(why.ToString());
}

Many Tks!
support wrote on 2013-10-18:
Hello,

You need to restructure your code so that:

http://toannn.no-ip.biz/admin/admin.export - renders the HTML page
http://toannn.no-ip.biz/admin/admin.export?pdf=1 - calls the API and returns PDF

It could look like this:
var ctx = HttpContext.Current;

if (Request.QueryString["pdf"]) {
    // your current code that calls the API
} else {
    // render the HTML page
}
tuanpa wrote on 2013-10-29:
Thank you for help me!