Skip to main content
Home  ›  Blog

Releasing 2sxc 8.10 - Public REST Api, Visual Query and WebApi + Shuffle DataSource

2sxc 8.10 offers four long awaited features - the ability to externally access REST APIs, App-WebApi and Visual Queries, + the ability to shuffle / randomize data-items.

Note for the quick: there's a demo/tutorial app to discover and learn the APIs.


2sxc allows JavaScript apps to read/write content-items using a REST api. Till now, the server required your JS-code to be inside DNN, so that it could check security etc. based on the module you were on. So previously, the endpoint would have been a bit like

  • .../api/auto/content/BlogPost (GET all BlogPost items, POST new item)
  • .../api/auto/content/BlogPost/5063 (GET one item, POST updates, DELETE)

In 2sxc 8.10 we've enhanced this with the ability to access it from external. Scenarios can be things like

  1. JS code in your skin, which retrieves data from a 2sxc Glossary-App to highlight words
  2. JS code in generic Apps, which may generically visualize a list of content-items
  3. JS code in other web sites, which should be allowed to access or even edit content-items

Note that all these scenarios will only work, if the security has been opened for this kind of use. In these new cases, the REST API now lets you specify the app-name, like this:

  • .../api/Blog/content/BlogPost
  • .../api/Blog/content/BlogPost/5063

Security Configuration For REST API

As always, everything must be explicitly opened for this to work. To allow DNN-level access (from the context/module itself) you are able to continue using the "Has Read = Let him also Read JSON" etc. But for real, external access, you must specify anonymous permissions, like this: 

Info About Root Path for External Access

The root path is usually hard-wired into the scripts accessing data from "external", since they can't ask $2sxc for the correct path. For this, there are two more things you must know:

  1. The root path for the api-call includes the portal identity. So the root path may be different depending on if it's a portal with domain only or with path. Example:
    1. would get it from the main portal
    2. would get it from the Demos portal
  2. The root path also varies by DNN version
    1. DNN 7 & 8: [root-domain/path]/desktopmodules/2sxc/api/app/...
    2. DNN 9: [root-domain/path]/api/2sxc/app/...

AngularJS Access Stays the Same

In AngularJS you would usually use 2sxc4ng and use the content service to read/write content-items. This stays the same. 

Public Visual Query API

Just as with the REST api, queries you create using the Visual Query Designer can also be accessed from "outside" if permissions have been opened. So here too you now have 2 options:

  1. .../api/auto/query/[QueryName]
  2. .../api/[app-name]/query/[QueryName]

Infos About Root-Path and AngularJS

  • root-path has the same aspecs as noted above with the REST API
  • AngularJS uses the query service just like before, if you are using 2sxc4ng
  • security permissions must be opened for this to work

Public WebAPI

Since 2sxc 5 or so, every 2sxc app can have it's own C# WebAPI for custom actions. This is basically c# files in the /api/ folder which can then be used by JS apps in the html. This is the same as the REST implementation:

  1. .../app/auto/api/[your-controller]/[your-action-name]
  2. .../app/[ppp-name]/api/[your-controller]/[your-action-name]

More specs

  1. Security is handled at C# level - for example, you need [AllowAnonymous] on a method to allow full external access
  2. AngularJS using the $http on 2sxc4ng continues to work as before
  3. root path has the same considerations as for REST

Fisher-Yates Shuffle / Randomize Data Source

Often you would like to randomize items from your data - like "show me only 4 random customers". There are many ways you can do this in code, but we spend a lot of time researching the most efficient way to do it - and implemented it as a data-source which you can use in visual query. 

So we're not using the classic "generate GUIDs and sort by these" which is inefficient, but a mathmatically sound (and fast!) Fisher-Yates shuffle.


In short, get 2sxc 8.10 and have fun. Also install out the tutorial app, to help you work with REST and more. 

Have fun :)

Daniel Mettler grew up in the jungles of Indonesia and is founder and CEO of 2sic internet solutions in Switzerland and Liechtenstein, an 20-head web specialist with over 800 DNN projects since 1999. He is also chief architect of 2sxc (see github), an open source module for creating attractive content and DNN Apps.

Read more posts by Daniel Mettler