Import ZIP files into Nuxeo 10 using rest API

Hi, I have exported a PDF file from Nuxeo as a ZIP through the web ui. I would like to import the ZIP back into Nuxeo using the rest API. When I use the drag-and-drop import functionality of the web ui, I am able to successfully upload the ZIP. The ZIP appears to replace/update the original PDF (with metadata attached) and the PDF can be viewed in the ui. I would like to replicate this functionality with the rest API. I have been following and tweaking the curl commands on this page, however the result does not match the web ui import functionality. When using the rest API, the ZIP uploads to a new document (does not update the original PDF) and the new document contains the XML and blob files of the ZIP (does not render as a PDF with attached metadata). I have also been following and tweaking the curl commands on this page, however when I run this command: curl -X POST -H “Content-Type: application/json+nxrequest” -d '{“params”:{“operationId”:“FileManager.Import”,“batchId”:“mybatchid”},“context”:{“currentDocument”:“/default-domain/workspaces/workspace”} }' -u Administrator:Administrator http://localhost:8080/nuxeo/site/automation/batch/execute I get the following error: {“entity-type”:“exception”,“status”:404,“message”:“com.sun.jersey.api.NotFoundException: null for uri: http://localhost:8080/nuxeo/site/automation/batch/execute”} I would appreciate any help, resources, or guidance. Thanks!

0 votes

1 answers

147 views

ANSWER



Hello,

Maybe a stupid question: have you set the correct batchid in your request (“batchId”:“mybatchid”) ? You should use the batchid providen by /nuxeo/api/v1/upload request as described in https://doc.nuxeo.com/nxdoc/howto-upload-file-nuxeo-using-rest-api/.

A good way to understand what is happening in Web UI is to open the network tab of your browser console and inspect each REST API Call (Nuxeo Web UI relies 100% on our REST API).

Regards

0 votes



Thank you for your help! I was setting the correct batchid, but was unaware I could view the API calls used by the web ui.
05/27/2021