Skip to main content
Skip table of contents

4.0 Requesting Content Types and Entries

Introduction

The Forrit.Consumers SDK offers several APIs for retrieving Content Types and Content Entries. In this section, you’ll learn what these APIs are and how to use them.

Overview

The following APIs (and their overloads) are included in Forrit.Consumers.Services.ContentService:

  1. GetContentManifestAsync: gets a manifest of all Content Types and Content Entries

  2. GetContentTypesAsync: gets all Content Types

  3. GetContentTypeAsync: gets a single Content Type

  4. GetContentEntriesForTypeAsync: gets all Content Entries for a particular Content Type

  5. GetContentEntryForTypeJsonAsync: gets a single Content Entry

Accessing the APIs

The APIs can be accessed using the ContentService from Forrit.Consumers.Services. You usually do this by injecting IContentService in a .NET Consumer Application.

The content service

For simplicity, a pseudocode version of the IContentService definition is shown below.

You can see the method overloads that allow resources to be requested by either name or ID.

C#
public interface IContentService
{
    // Get the content manifest
    GetContentManifestAsync();

    // Get all content types
    GetContentTypesAsync();

    // Get a single content type
    GetContentTypeAsync(Guid typeId);
    GetContentTypeAsync(string typeName);

    // Get all content entries for a particular content type
    GetContentEntriesForTypeAsync(Guid typeId);
    GetContentEntriesForTypeAsync(string typeName);

    // Get a single content entry as JSON
    GetContentEntryForTypeJsonAsync(Guid typeId, Guid entryId);
    GetContentEntryForTypeJsonAsync(string typeName, Guid entryId);
    GetContentEntryForTypeJsonAsync(Guid typeId, string entryName);
    GetContentEntryForTypeJsonAsync(string typeName, string entryName);
}

You can request content by either name or ID

You can fetch content either by its name or by its ID. This means you can immediately request content, as long as you know its name, without having to make preceding requests to find IDs.

Content is always requested from the latest Release

All of the API calls request content from the latest Release published to your Consumer Application.

APIs

The ContentService API calls from are summarised below.

1. GetContentManifestAsync

Gets the content manifest, which includes the names and IDs of all Content Types and Content Entries.

You can use this to retrieve Content Type and Content Entry names and IDs for subsequent API calls.

2. GetContentTypesAsync

Gets a list of all Content Types, which includes their names and IDs.

You can use this to retrieve Content Type names and IDs for subsequent API calls.

Similar to the content manifest but does not include Content Entry information.

3. GetContentTypeAsync

Gets a single Content Type.

You must pass the name or ID of the Content Type.

Similar to GetContentTypesAsync but for a single Content Type.

4. GetContentEntriesForTypeAsync

Gets all of the Content Entries for a particular Content Type.

You must pass the name or ID of the Content Type.

Each Content Entry includes the content for every configured Locale.

5. GetContentEntryForTypeJsonAsync

Gets a single Content Entry as a JSON string.

You must pass the name or ID of both the Content Entry and the Content Type.

Only the content of a single Locale is returned – based on your ILocaleProvider implementation (by default from the query string). For more information about ILocaleProvider, see creating a Page-based app.

Outcome

In this section, you’ve learned:

  • The various API methods for requesting Content Types and Content Entries

  • The differences between the APIs

  • How to call them

JavaScript errors detected

Please note, these errors can depend on your browser setup.

If this problem persists, please contact our support.