Question
C# code works on localhost but not server error 503
I have an issue with the Adobe Acrobat Service API.
The code is nearly identical to the official .net example given and works when I run the application in localhost. However on the server using the same client id and secret it fails with a message:
ServiceApiException [message =Error response received for the request: The Gateway servers are up, but overloaded with requests. Try again later., requestId = cc6cf0d4-c2ed-4a42-ae71-4418bdd1489a, httpStatusCode = 503, errorCode = UNKNOWN]
Please help. here is my code which works on localhost not server. I am an admin on a corporate account, not free tier.
public static void RunDocxToPdfConvert(string pathToDocx, string pathToPDF)
{
try
{
Adobe.PDFServicesSDK.auth.ICredentials credentials = new ServicePrincipalCredentials(
Environment.GetEnvironmentVariable("PDF_SERVICES_CLIENT_ID"),
Environment.GetEnvironmentVariable("PDF_SERVICES_CLIENT_SECRET"));
// Creates a PDF Services instance
PDFServices pdfServices = new PDFServices(credentials);
// 3) Upload the DOCX as an Asset
try
{
using (Stream inputStream = File.OpenRead(pathToDocx))
{
//Blows up on the next line
IAsset docxAsset =
PdfServices.Upload(inputStream,
PDFServicesMediaType.DOCX.GetMIMETypeValue());
// 4) Create & submit the Create PDF job
CreatePDFJob createPdfJob = new CreatePDFJob(docxAsset);
string location = pdfServices.Submit(createPdfJob);
// 5) Poll for result
PDFServicesResponse<CreatePDFResult> response =
pdfServices.GetJobResult<CreatePDFResult>(location, typeof(CreatePDFResult));
// 6) Download the resulting PDF
IAsset resultAsset = response.Result.Asset;
StreamAsset streamAsset = pdfServices.GetContent(resultAsset);
using (Stream outputStream = File.OpenWrite(pathToPDF))
{
streamAsset.Stream.CopyTo(outputStream);
};
}
}
catch (Exception ex)
{
Log.Error(ex.ToString());
}
}
catch (ServiceUsageException ex)
{
Log.Error("Service usage exception encountered while executing operation" + ex.ToString(), ex);
}
catch (ServiceApiException ex)
{
Log.Error("Service API exception encountered while executing operation", ex);
}
catch (SDKException ex)
{
Log.Error("SDK exception encountered while executing operation", ex);
}
catch (IOException ex)
{
Log.Error("I/O exception encountered while executing operation", ex);
}
catch (Exception ex)
{
Log.Error("Unexpected exception encountered while executing operation", ex);
}
}