Closed MateuszRosinski1 closed 9 months ago
Are you sure your export task has the name export_task
?
Other than that, please use a debugger and check the objet attributes.
here is the relevant code:
var job = await _cloudConvert.CreateJobAsync(new JobCreateRequest
{
Tasks = new
{
import_task = new ImportUploadCreateRequest(),
convert_task = new ConvertCreateRequest
{
Input = "import_task",
Input_Format = "pdf",
Output_Format = "docx"
},
export_task = new ExportUrlCreateRequest
{
Input = "convert_task",
Archive_Multiple_Files = false
}
},
Tag = "Test"
});
string path = @"D:/test/testpdf.pdf";
byte[] file = await File.ReadAllBytesAsync(path);
string filename = "testpdf.pdf";
var uploadTask = job.Data.Tasks.FirstOrDefault(t => t.Name == "import_task");
await _cloudConvert.UploadAsync(uploadTask.Result.Form.Url.ToString(), file, filename, uploadTask.Result.Form.Parameters);
var completedJob = await _cloudConvert.WaitJobAsync(job.Data.Id);
var exportTask = job.Data.Tasks.FirstOrDefault(t => t.Name == "export_task");
var exportFile = exportTask.Result.Files.FirstOrDefault();
As you can she export task name is export_task
, digging into the attributes i can she that the job status is finished
Regardless of that
exportTask.Results = null
I found the solution and apologize for my foolishness and working in a hurry. I completely overlooked the fact that there should be two separate jobs, for example, 'job' and 'job2,' instead of one combined task. I won't delete this thread as a warning for other juniors. I apologize for the confusion and wasted time, and despite everything, I would like to thank you for the quick response. WRONG:
var completedJob = await _cloudConvert.WaitJobAsync(job.Data.Id);
var exportTask = job.Data.Tasks.FirstOrDefault(t => t.Name == "export_task");
var exportFile = exportTask.Result.Files.FirstOrDefault();
GOOD:
var completedJob = await _cloudConvert.WaitJobAsync(job.Data.Id);
var exportTask =completedJob.Data.Tasks.FirstOrDefault(t => t.Name == "export_task"); //<-- here was a mistake.
var exportFile = exportTask.Result.Files.FirstOrDefault();
I would like to mention that the opening comment, more precisely, the code located above this comment, is incorrect and was later corrected.
This is the part that confused me. As you can see in both screenshots, there is "job" in both cases. However, when combining these code snippets, they should be two separate jobs. In the WaitJobAsync(job.Data.Id
method, it should, of course, be "the first job."
creation of job with taskts
creating completed job
At the end, I would like to apologize again and wish you all good.
I'm currently working on integrating CloudConvert API into my application, and I'm encountering an issue with obtaining the result of a completed job.
After waiting for the job to complete using
WaitJobAsync
, thecompletedJob
status is "finished," indicating that the job finished successfully. However, when I try to accessexportTask.Result
, it appears to be null.Here is a snippet of my code:
I have confirmed that the job is completing successfully, but I'm unable to access the Result property of exportTask. Could you please provide guidance on what might be causing exportTask.Result to be null despite a successful job completion?
Thank you for your assistance.