2sxc Web API Documentation
GET to an endpoint like
app/News/content/NewsItems/ and get a list of news items.
You can also create / modify data using REST, access Queries and work with your custom Web-APIs - across all 2sxc platforms (Dnn / Oqtane / Custom) and with the security you need.
// Get news as a promise var allNewsPromise = sxc.webApi.get('app/auto/content/News/'); // now log to console allNewsPromise.then(data => console.log(data));
This example has some magic happening in the background. Specifically 3 important things happen on the client before sending:
- The real URL which is requested is a bit longer, but the
webApitakes care of that.
- The server needs to know what App and Module the script is calling from. This Context information is also added by the
When the server receives the request, it too does important stuff.
- First it will use the URL and Context information to figure out what Site, Language and App should be accessed.
- The server will do some security checks to see if this request should be answered.
- Then it returns the data in a simple JSON format
Get Started Step 1: Decide which Endpoint you need
This checklist should help you decide:
Your 1-2-3 steps for using data endpoints are:
- Decide which endpoint you need
- Create / Publish the endpoint
- For standard endpoints, set the permissions as you need them
- For custom endpoints, write the C# code
- REST means that there is a url convention to access data like
- REST also specifies that an HTTP GET is for reading, HTTP POST is for writing, etc.
- All the APIs use JSON for sending/receiving data. This is the default schema.
Demo App and further links
You should find some code examples in this demo App
- Introduced Content-REST API in 2sxc 5.x
- Query added in 2sxc 8.10
- Enhanced with Polymorph Editions in 2sxc 9.35 (allowing subfolder/api)