Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
Load data from the DNN Evoq Liquid Content API using the DNN Razor Host module. Razor gives you a bit more control and flexibility than the built-in visualizers.
@using System
@using System.Net
@using System.Text
@using Newtonsoft.Json
@using Newtonsoft.Json.Linq
// The API URL and your API Key
string url = "";
string apikey = "**** INSERT YOUR API KEY HERE ****";
// Declare the result variables
string lcjson = String.Empty;
string err = String.Empty;
JObject lcObject = null;
JArray items = null;
IEnumerable<Newtonsoft.Json.Linq.JToken> jobs = null;
// First, we'll set up the http request
var myWebRequest = WebRequest.Create(url);
var myHttpWebRequest = (HttpWebRequest)myWebRequest;
myHttpWebRequest.Method = "GET";
myHttpWebRequest.PreAuthenticate = true;
myHttpWebRequest.Headers.Add("Authorization", "Bearer " + apikey);
myHttpWebRequest.Accept = "application/json";
// Get the JSON response from the API
var myWebResponse = myHttpWebRequest.GetResponse();
var responseStream = myWebResponse.GetResponseStream();
if (responseStream != null) {
var myStreamReader = new StreamReader(responseStream, Encoding.Default);
lcjson = myStreamReader.ReadToEnd();
catch(Exception ex)
err = ex.ToString();
// Parse JSON into an object
if (lcjson != String.Empty)
lcObject = JObject.Parse(lcjson);
items = (JArray)lcObject["documents"];
jobs =
from j in items
select j["details"];
<div class="container">
<div class="row">
<!-- If we have an error, tell the user what went wrong -->
@if (err != String.Empty)
<div class="col mb-4 bump bump-primary">@err</div>
<!-- List of jobs -->
<div class="col-12 mb-4">
<h2>@jobs.Count() vacancies in the system</h2>
@foreach (var x in jobs)
<div class="col mb-4">
<div class="card">
<div class="card-body">
<h5 class="card-title">
<p class="card-text">
<!-- Here's the JSON data from the Liquid Content API -->
<div class="col mb-4">
<div class="bump bump-primary">
<!-- Don't forget we have full access to the DNN API here -->
<div class="col mb-4">
<div class="bump bump-primary">
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment