4 Replies Latest reply on Mar 16, 2015 9:26 AM by Stefan Nägele

    File upload via REST API

    Stefan Nägele Newbie

      Hello everyone,


      I was browsing the REST API documentation (REST Service 3.x - ModeShape 3 - Project Documentation Editor, I'm using Modeshape 3.8.1) but I did not find any references how to create a file node with a specific file content (xml, zip etc.).


      I already used the JCR ModeShape API (...addNode("myfile.xml", "nt:file") ...addNode("jcr:content")... createBinary(..).. setProperty("jcr:data"...) or JcrTools uploadFile("my/fancy/path/to/myFile.xml", File file) and (of course) those approaches worked fine.


      But now I would like to use a REST client call to create nodes and upload files in my repository.



      Currently I'm sending up the following POST request:


      - http://localhost:8080/modeshape-rest/artifacts/default/items/

      - Content type is set to application/json


      Http Body:



          "testNode" : {



          "testNode/child" : {



          "testNode/child/subChild" : {



          "testNode/child/subChild/test.xml" : {


           # what to do here





      Now I'm wondering how to put my file stream/content (actually a Zip) into the JSON object body.


      Btw: is the programmatically Modeshape REST Client API (https://access.redhat.com/documentation/en-US/JBoss_Enterprise_Data_Services/5/html/Metadata_Repository_Reference_Guide/web_access.html#modeshape_rest_client_api) an option for Modeshape 3.8.1? Afaik it is deprecated.