Using LINQPad to Access Headless CMS

You can use LINQPad ( to access headless Content Management Systems with C# code. LINQPad provides convenient visualizers for JSON and images. You can use LINQPad for scripting, and both visualized and raw access the JSON can be useful when implementing Entry Model classes (see, diagnosing issues, and otherwise.

The code in the following image uses the Contentstack .NET SDK (, AKA, also at to retrieve an Entry (,, from the CMS and render a server-side manipulated Asset ( ) referenced by that Entry.

LINQPad accessing the Contentstack Headless CMS.

To achieve this in LINQPad:

  1. Download the Contentstack.Csharp (, Newtonsoft.Json (, andMicrosoft.Extensions.Options ( NuGet packages.
  2. Use a compression tool such as 7-Zip ( to extract the /contentstack.csharp.2.3.0.nupkg/lib/netstandard2.0/Contentstack.Core.dll, /newtonsoft.json.12.0.3.nupkg/lib/netstandard2.0/Newtonsoft.Json.dll, and /microsoft.extensions.options.3.1.6.nupkg/lib/netstandard2.0/Microsoft.Extensions.Options.dll assemblies from the NuGet packages to a temporary directory such as C:\temp.
  3. In LinqPad, press F4 or select the Query menu and then select References and Properties to open the Query Properties dialog.
  4. On the Additional References tab, click the Add / Browse button and add the two libraries.
  5. On the Namespace Imports tab, add Contentstack.Core, Contentstack.Core.Models, and Newtonsoft.Json.Linq namespaces.

Additional References tab:

LNIQPad referencing assemblies.

Imports tab:

LINQPad importing namespaces.

In LINQPad, you do not need a namespace, class, or Main() method, only the lines of code to execute. Look for output on the Results tab.

Here is some sample code to access an existing Entry and an Asset in an existing Environment in an existing Stack with an existing Content Delivery Token in the Contentstack SaaS headless CMS:

ContentstackClient stack = new ContentstackClient(
Entry entry = stack.ContentType("product").Entry(
JObject entryJson = entry.ToJson();

foreach (var image in entryJson.SelectTokens("$.images").Children())
    string url = image["url"] + "?w=25p";


Of course, you would normally use Entry Models ( to model Entries and to access Asset metadata including URLs rather than accessing the processing the raw JSON directly.

One thought on “Using LINQPad to Access Headless CMS

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: