Copy link to clipboard
Copied
Hi Team,
I'm trying to use the Adobe PDF Services API to convert pdf to word using the Export end point.On calling the poll method I'm getting the below response.
var request = new RestRequest();
request.Method = Method.Post;
request.AddQueryParameter("respondWith=", queryparam);
request.AddHeader("Authorization", token);
request.AddHeader("Accept", "application/json,text/plain,*/*");
request.AddHeader("x-api-key", clientId);
request.AddHeader("Prefer", "respond-async,wait=0");
request.AddHeader("content-type", "multipart/form-data; boundary=----boundary");
request.AddParameter("multipart/form-data; boundary=----boundary",
"------boundary\r\nContent-Disposition: form-data; name=\"contentAnalyzerRequests\"\r\n\r\n" + jsonString +
"\r\n------boundary\r\nContent-Disposition: form-data; name=\"InputFile\"\r\n\r\n" + path + // loacl Path were we keep the pdf file.
"\r\n------boundary--", ParameterType.RequestBody);
RestResponse adobeResponse = client.ExecuteAsync(request).Result;
contentAnalyzerRequests body:
{"cpf:inputs":{"params":{"cpf:inline":{"targetFormat":"docx"}},"documentIn":{"cpf:location":"InputFile","dc:format":"application/pdf"}},"cpf:engine":{"repo:assetId":"urn:aaid:cpf:Service-26c7fda2890b44ad9a82714682e35888"},"cpf:outputs":{"documentOut":{"cpf:location":"multipartLabelOut","dc:format":"application/vnd.openxmlformats-officedocument.wordprocessingml.document"}}}
Response:
{"cpf:status":{"completed":false,"type":"","title":"In Progress","status":202},"cpf:engine":{"repo:assetId":"urn:aaid:cpf:Service-26c7fda2890b44ad9a82714682e35888"},"cpf:inputs":{"params":{"cpf:inline":{"targetFormat":"docx"}},"documentIn":{"cpf:location":"InputFile","dc:format":"application/pdf"}}}
Copy link to clipboard
Copied
Hi, can you share your PDF? If it is private, you can email it to me directly at jedimaster@adobe.com.
Copy link to clipboard
Copied
Hi, I tried with any pdf file(not specific to our requirement) getting same error you can also reach out to Darakhshan Khan <darkhan@adobe.com> i have shared a sample pdf to her.
Copy link to clipboard
Copied
Ok - then it may be in how you are using the REST API. I'm not familiar with the language you are using. Are you sure you are properly creating the multipart request and sending the binary data to the endpoint?
Copy link to clipboard
Copied
Yes the request is multipart since I'm getting initial response status as 202,I tried changing the above code to some other format got error as not multipart request.
Could you please elaborate on the binary data part.
Note: If I'm using the same contentAnalyzerRequests body in postman and the file path I'm able to convert the pdf.
Complete code is in c#
Copy link to clipboard
Copied
To be clear, I meant the *response* is multipart. Your code takes it and saves it as is, but it needs to parse it first.
Copy link to clipboard
Copied
response from Export end point gives status as 202,title":"In Progress", then as per document we call the poll method from there we are getting the "CORRUPT_DOCUMENT\" , so I'm not able to save any response.
We are following the below document
Copy link to clipboard
Copied
I believe you want to wait till the result says Completed. From the docs: "the state of the request for e.g. In Progress
, Completed
. In case of Failure, a descriptive error message will be returned"
Copy link to clipboard
Copied
In the response header of POST call a Poll location URL is returned to get the generated output file, while polling the same method we are getting the above "CORRUPT_DOCUMENT\" message.
Copy link to clipboard
Copied
Right - but I believe you can't get the location until the status is complete though. Did you wait for that?