Question
Bad Address
When I make HTML TO PDF API using .Net SDK I get this error
"{"Bad Address, request terminated; requestId=8a16cea5-deb2-4d6b-a044-74b4e0451467"}"
private async Task<Stream> CreateFromHtmlStream(Stream htmlDataStream)
{
try
{
// Initial setup, create credentials instance
var credentials = GetCredentials();
// Creates a PDF Services instance
var pdfServices = new PDFServices(credentials);
// Creates an asset(s) from source file(s) and upload
var asset = pdfServices.Upload(htmlDataStream, PDFServicesMediaType.HTML.GetMIMETypeValue());
// Create parameters for the job
var htmlToPDFParams = GetHtmlToPdfParams();
// Creates a new job instance
var htmlToPdfJob = new HTMLToPDFJob(asset).SetParams(htmlToPDFParams);
// Submits the job and gets the job result
var location = pdfServices.Submit(htmlToPdfJob);
var pdfServicesResponse = pdfServices.GetJobResult<HTMLToPDFResult>(location, typeof(HTMLToPDFResult));
// Get content from the resulting asset(s)
var resultAsset = pdfServicesResponse.Result.Asset;
var streamAsset = pdfServices.GetContent(resultAsset);
// Save the PDF to a temporary file
var tempPdfFilePath = Path.GetTempFileName();
using (var tempPdfStream = new FileStream(tempPdfFilePath, FileMode.Create, FileAccess.Write))
{
streamAsset.Stream.CopyTo(tempPdfStream);
}
// Convert the PDF to Word
var outputStream = ConvertPdfToWordStream(tempPdfFilePath);
// Clean up temporary PDF file
System.IO.File.Delete(tempPdfFilePath);
return outputStream;
}
catch (ServiceUsageException ex)
{
//_logger??.LogError("Exception encountered while executing operation", ex);
}
catch (ServiceApiException ex)
{
//_logger??.LogError("Exception encountered while executing operation", ex);
}
catch (SDKException ex)
{
//_logger??.LogError("Exception encountered while executing operation", ex);
}
catch (IOException ex)
{
//_logger??.LogError("Exception encountered while executing operation", ex);
}
catch (Exception ex)
{
//_logger??.LogError("Exception encountered while executing operation", ex);
}
return null;
}My API code is copied above. I am clueless to find what is going on here. I am trying to send HTML to our RESTful POST endpoint & perform this operation.
Please help me asap because we are evaluvating this service to buy coporate licence.
