Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Comment: Add /content/config.author POST workaround

...

The TypeHint tells the Sling POST servlet to create a multi-value property for foo.

I cannot add a node under /content/config.author using a POST, the new node goes under /content/config

That happens if both the /content/config.author and /content/config nodes exist, and you do something like:

Code Block

$ curl -F try=first -u admin:admin http://localhost:8080/content/config.author/underauthor

The underauthor node goes under /content/config in that case, as Sling finds a resource at that path and considers .author as an extension or selector.

This is inherent to the way Sling matches URL paths to resources - to work around that, use

Code Block

$ curl -F underauthor/try=second -F "underauthor/jcr:primaryType=sling:Folder" -u admin:admin http://localhost:8080/content/config.author

Which correctly creates the underauthor node under /content/config.author. You can of course add more properties to the request, like -F underauthor/jcr:primaryType if needed.

Here's the resulting content of our example (including specifying the jcr:primaryType):

Code Block

$ curl http://localhost:8080/content.tidy.5.json
{
  "jcr:primaryType": "nt:unstructured",
  "config.author": {
    "foo": "bar",
    "jcr:primaryType": "nt:unstructured",
    "underauthor": {
      "try": "second",
      "jcr:createdBy": "admin",
      "jcr:created": "Fri Jan 25 2013 17:35:18 GMT+0100",
      "jcr:primaryType": "sling:Folder"
    }
  },
  "config": {
    "foo": "bar",
    "jcr:primaryType": "nt:unstructured",
    "underauthor": {
      "try": "first",
      "jcr:primaryType": "nt:unstructured"
    }
  }
}

Scripts and Servlets

How do I generate links to previous versions of a node?

...