CRUD content via rest api

Hello
I want to create some new content like new document via rest api. Is there any rest api like POST api/content/documents or api/content/gallery to save new document or image in the cms?
I see this post but I want some api like this for managing all entity like node, property, user and group. This plugin did not compatible with bloomreach 13. Is there a similar one for bloomreach 13? If no how can I write some api like this?
Thanks.

Hi,

You have two options to implement and expose JAX-RS based REST services:

  • Repository JAX-RS Service [1]
  • Plain JAX-RS Services [2]

The former one is deployed on /cms application, whereas the latter is on /site application. The former with built-in Basic authentication, the latter without built-in authentication - but you can add authentication through Spring Security and integration addon module [3] for example.

REST endpoints allow you to expose URLs, input and output params, so you need to use a API or library to create documents in repository. Content-EXIM [4] is a good library in any choices. For example, the groovy code example with the library [5] is a good source to reuse.

Regards,

Woonsan

[1] https://documentation.bloomreach.com/library/concepts/hippo-services/repository-jaxrs-service.html
[2] https://documentation.bloomreach.com/library/concepts/rest/restful-api-support---plain-jax-rs-services.html
[3] https://bloomreach-forge.github.io/hst-spring-security/
[4] https://bloomreach-forge.github.io/content-export-import/
[5] https://bloomreach-forge.github.io/content-export-import/tutorials-import-docs.html

Thanks.
For adding repository jaxrs service I add new module and a class like documentation. After build and run project, the api return

No service was found

I add the new maven module in root of project. Then add the provided dependency and api class. Is there any sample project?

Perhaps there are better ones, but I have this: Content EXIM Built-in REST Services

Click on “Fork me on GitHub” ribbon and browse the “repository-jaxrs” submodule.

Regards,

Woonsan

I get this message even with the sample project (conten-exim) !
Any additional tipps ??

I found out that the url I used was wrong:
instead of http://localhost:8080/cms/ws/exim/export, I used http://localhost:8080/cms/ws/export

Consuming the webservice via curl, as described with the sample-project - works fine (I am only not able the read the zip-file).

But how can I consume the webservice via a http-client. I am using YARC to test it. With the following header I get a 400-response!

this is my request-header:

    {
        "method": "POST",
        "transformRequest": [
         null
         ],
        "transformResponse": [
         null
         ],
         "url": "http://localhost:8080/cms/ws/exim/export",
         "headers": {
            "paramsJson": "{ documents: { queries: [ 
             '/jcr:root/content/documents//element(*,hippo:document)' ] } }",
          "Content-Type": "multipart/form-data",
          "Accept": "application/octet-stream",
          "Authorization": "Basic YWRtaW46YWRtaW4="
       },
       "data": "",
       "timeout": {}
    }

What is wrong with the request ?

In the meanwhile I found the solution and I woud like to share it with the community.
The paramsJson has to go in the data section as payload!

"data": "paramsJson = \"{ documents: { queries: [ '/jcr:root/content/documents//element(*,hippo:document)' ] } }\""

Hey Woonsan,

Greetings

As per your suggestion, we are using " Content EXIM Built-in REST Services" for CRUD operations like Create-item, Get-Item, Publish-item. Somewhere while achieving this, We are having issues in modifying an item using “PUT”. Every time hitting “PUT” to modify field values it changes the UUID.

I’m very thankful If you can help here or suggest something.

Thanks
Param

CMS workflow may updates the UUIDs of a document variant node or descendant nodes at any time, but its handle node’s (parent node of the document variant nodes) uuid will never change.

Regards,

Woonsan

1 Like