Skip to main content
Participant
April 16, 2024

Getting 'Error response received for the request: A connection attempt failed

  • April 16, 2024
  • 1 reply
  • 294 views

I am getting the below error when trying to convert PDF to Excel.

Adobe.PDFServicesSDK.exception.ServiceApiException: 'Error response received for the request: A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond. (pdf-services.adobe.io:443)'

 

i am using below code to convert the data with free tier of Adobe credentials.

 

using Adobe.PDFServicesSDK;
using Adobe.PDFServicesSDK.auth;
using Adobe.PDFServicesSDK.exception;
using Adobe.PDFServicesSDK.io;
using Adobe.PDFServicesSDK.options.exportpdf;
using Adobe.PDFServicesSDK.pdfops;
using System;
using System.IO;
using System.Reflection;

try
{
// Initial setup, create credentials instance.
Credentials credentials = Credentials.ServicePrincipalCredentialsBuilder()
.WithClientId("1dc3e457fe79489897cc229d57ae107c")
.WithClientSecret("p8e-UM_dJ_0l_Seb0dTRi4Oi6voIAhGWXiJb")
.Build();
string fileName = "P123879.pdf";
string filePath = System.IO.Path.Combine("E:\\AdobePDF\\PDF Scrapping\\ConsoleApp1", @"Files\", fileName);
//Create an ExecutionContext using credentials and create a new operation instance.
Adobe.PDFServicesSDK.ExecutionContext executionContext = Adobe.PDFServicesSDK.ExecutionContext.Create(credentials);
ExportPDFOperation exportPdfOperation = ExportPDFOperation.CreateNew(ExportPDFTargetFormat.DOCX);

// Set operation input from a local PDF file
FileRef sourceFileRef = FileRef.CreateFromLocalFile(filePath);
exportPdfOperation.SetInput(sourceFileRef);

// Execute the operation.
FileRef result = exportPdfOperation.Execute(executionContext);

//Generating a file name
String outputFilePath = CreateOutputFilePath();

// Save the result to the specified location.
result.SaveAs(Directory.GetCurrentDirectory() + outputFilePath);

}
catch (ServiceUsageException ex)
{
Console.WriteLine("Exception encountered while executing operation", ex);
}
catch (ServiceApiException ex)
{
Console.WriteLine("Exception encountered while executing operation", ex);
}
catch (SDKException ex)
{
Console.WriteLine("Exception encountered while executing operation", ex);
}
catch (IOException ex)
{
Console.WriteLine("Exception encountered while executing operation", ex);
}
catch (Exception ex)
{
Console.WriteLine("Exception encountered while executing operation", ex);
}
static string CreateOutputFilePath()
{
String timeStamp = DateTime.Now.ToString("yyyy'-'MM'-'dd'T'HH'-'mm'-'ss");
return ("/output/export" + timeStamp + ".docx");
}

 

getting the issue in the highlighted red line of code.

 

we have whitelisted both the required URLs : 

1) https://developer.adobe.com/document-services/docs/overview/pdf-extract-api/

2) https://pdf-services.adobe.io/

 

please let us know why we are getting the above issue as we are using same code which is being provided in the zip file with free tier.

1 reply

Participant
April 19, 2024

I have 2 queries while using the above mentioned code:- 

1) I want to set the proxy in the code provided to convert pdf into Excel, since all the methods are predefined i am not able to set the proxy please guide me for same

 

String proxyURL = "proxyURL:Port";
WebProxy webProxy = new WebProxy(proxyURL);

HttpClientHandler httpClientHandler = new HttpClientHandler
{
Proxy = webProxy,
UseProxy = true
};

how i can use the proxy to above predefined code which has been provided by Adobe. In .net 6 

 

2) getting the issue "Error response received for the request: Cannot send a content-body with this verb-type." RequestID : "7a37300a-6f46-478a-a2f0-1b440ee07107" for the same above code which has been provided by Adobe.

 

Kindly please provice the solution for above queries