Client SDKs

Using cURL

Updated: March 18, 2024

In this example we are using the UNIX curl command line tool to demonstrate how to invoke remote operations.

In a Windows environment, Nuxeo recommends to use cygwin shell to avoid all formatting request issue using default shell like Powershell

  1. Here is how to create a new File document type on the Nuxeo demo instance, right under the default domain (you can copy, paste and test):

    curl -X POST -H "Content-Type: application/json" -u Administrator:Administrator -d '{ "entity-type": "document", "name":"newDoc", "type": "File","properties": { "dc:title": "Specifications", "dc:description": "Created via a so cool and simple REST API", "common:icon": "/icons/file.gif", "common:icon-expanded": null, "common:size": null}}' https://nightly.nuxeo.com/nuxeo/api/v1/path/default-domain
    
  2. You can get the new resource doing a standard GET (actually the JSON object was already returned in previous response):

    curl -X GET -u Administrator:Administrator  http://nightly.nuxeo.com/nuxeo/api/v1/path/default-domain/newDoc
    
  3. Now, "lock" this document we have just created by calling an Automation operation from command API on the document resource.

    curl -X POST -H "Content-Type: application/json+nxrequest"   -u Administrator:Administrator -d '{"params":{}}'  https://nightly.nuxeo.com/nuxeo/api/v1/path/default-domain/newDoc/@op/Document.Lock
    

    Pay attention to the Content-Type that is specific when using the @op adapter.

    You can check the result of your request on the web app (https://nightly.nuxeo.com/nuxeo/nxpath/default@view_domains, credentials:  Administrator/Administrator).

  4. You can also directly call an automation operation or chain, from the "Command endpoint". Here we return all the worskpaces of the demo.nuxeo.com instance:

    curl -H 'Content-Type:application/json+nxrequest' -X POST -d '{"params":{"query":"SELECT * FROM Document WHERE ecm:primaryType=\"Workspace\""},"context":{}}'   -u Administrator:Administrator https://nightly.nuxeo.com/nuxeo/api/v1/automation/Document.Query