Fork me on GitHub
2sxc 9.6 for DNN 7 to 9
Website Builder, Content Manager, App-System: open-source and amazing
You are here: Home  >  Learn  >  REST for JavaScript

Using REST for Content CRUD (Create, Read, Update, Delete)

2sxc 7.1 offers new, full REST support to get, create, update and delete content. Rest is basically a simple way to target a content-item with a URL and either read, write, delete etc.

The principle is very simple: use an HTTP-Verb like GET, POST, DELETE to access a resource. Example

  • GET .../app-content/Feedback
    will return all feedback items
  • GET .../app-content/Feedback/243
    will return the feedback item 243
  • POST .../app-content/Feedback
    with data like { Subject: "I love your product", Message: "Tried 2sxc, love it" }
    will create a new feedback item in the content-database
  • POST .../app-content/Feedback/243
    with data like { Subject: "Updated Subject"}
    will update the subject field and leave the rest untouched
  • DELETE .../app-content/Feedback/243
    will delete this content item

So what do you need to know to get started?

  1. By default the REST API only works for users who have at least Admin-permissions. To enable it for anybody else, you need to set the appropriate permissions. 
  2. The root URL of the API can change from system to system. There is an easy way to get the right path.
  3. DNN increases the security of WebAPI with something called a ServiceFramework. This ensures that only your modules can access the API and other, external sources can't. You need to know how to work with this. 
  4. If you've never used REST APIs before you will probably need some examples how to code the JavaScript using jQuery or AngularJS

Let's get started!

Download a jQuery Demo App

In the App-Store we provided a simple jQuery Demo App showing all CRUD operations. 

Try the AngularJS Demo App

This one shows a much more advanced solution using AngularJS. The great thing is that you can build upon this to create really awesome solutions. 

To be released at DNN Connect 2015

Configure Permissions

Here we explain how to work with permissions.

Security with the DNN Services Framework

If you follow the code-examples you don't need to understand this. But if you need to know more, read about it here. 

2serve . 2invent . 2create is 2be.