The Cloud CMS content API lets you work with JSON to create any kind of content you'd like. It supports any JSON structure you desire and also supports a number of special properties that you can use to make life easier for you.
These special properties are:
- _rootNodeId - The mount node ID of the root against which relatives path are computed. By default, this is the root of the repository. In general, it isn't necessary to use this property unless you have multiple mount nodes configured. And most people do not.
- _parentFolderPath - The path to the parent folder into which the newly created content should be placed. This works hand-in-hand with the "_fileName" property below.
- _fileName - The WebDAV/FTP compatible filename for the newly created item. This works hand-in-hand with the "_parentFolderPath" property above. If a filename isn't provided, then one is computed by default from the "title" or "_doc" of the node.
- _filePath - The full path to the newly created content item. Use this as an alternative to the "_parentFolderPath/_fileName" combination properties from above.
- _associationTypeString - The type of association to create linking the parent to the child. By default, this is "a:child".
One of the most common scenarios is one whereby you wish to create a piece of content in a particular folder. For example, you might have a piece of content like this:
{ "title": "My Article", "body": "This is the article's body" }
Suppose you wanted to create content at the following path:
/Content/Articles/MyArticle
To do so, you need to do the following:
- Ensure that the folders /Content/Articles/MyArticle exist ahead of time or create them programatically.
- Read the MyArticle parent folder.
- Create the article above
- Link the new article to the parent folder via an association (usually a:child).
That's a lot of steps. Fortunately, you can do this all in one fell-swoop using the following JSON:
{ "title": "My Article", "body": "This is the article's body", "_parentFolderPath": "/Content/Articles", "_fileName": "MyArticle" }
Or
{ "title": "My Article", "body": "This is the article's body", "_filePath": "/Content/Articles/MyArticle" }
That's it. Enjoy!