Skip to content
This repository was archived by the owner on Oct 5, 2022. It is now read-only.

Content management REST API

Mike Budzynski edited this page Oct 31, 2019 · 36 revisions

New developer portal is a static web application, which relies on the content management API. The content management API is an endpoint in the Azure API Management REST API. You can access it directly or through the Azure Resource Manager (ARM). For simplicity, we will assume you use the direct access API.

Unlike classic CMSes, which store content in form of HTML, the developer portal outputs structured JSON. Every element from a page layout to a hyperlink has a strictly-defined contract. This approach allows to abstract data from its representation, ensure content consistency, avoid mixing different types of data, build JSON-based ARM templates, and more.

Authentication

You need to obtain an access token to start using the direct access API.

Content types

A content type is an entity describing a content item, its properties, validation rules, and constraints.

The following content types are built-in and can't be modified or removed: Pages, Layouts, Blog posts, Blobs, URLs, Design blocks, Styles, Documents.

Get

Retrieve all content types:

GET /contentTypes

Response example:

{
    "value": [{ ... }, { ... }, { ... }],
    "count": 8,
    "nextLink": null
}

Create or update

Manage a content type:

GET,PUT,PATCH,DELETE /contentTypes/{contentTypeId}

Note:

  • You can't perform operations other than GET on the built-in content types
  • Custom content types ids need to start with the c- prefix

Response example:

{
    "id": "/contentTypes/page",
    "type": "Microsoft.ApiManagement/service/contentTypes",
    "name": "page",
    "properties": {
        "title": "Page",
        "description": "A regular page",
        "version": "1.0.0",
        "schema": {
            "properties": {
                "en_us": {
                    "$ref": "#/definitions/metadata"
                }
            },
            "additionalProperties": false,
            "definitions": {
                "metadata": {
                    "type": "object",
                    "properties": {
                        "title": {
                            "title": "Title",
                            "description": "Page title. This property gets included in SEO attributes.",
                            "type": "string",
                            "indexed": true
                        },
                        "description": {
                            "title": "Description",
                            "description": "Page description. This property gets included in SEO attributes.",
                            "type": "string",
                            "indexed": true
                        },
                        "keywords": {
                            "title": "Keywords",
                            "description": "Page keywords. This property gets included in SEO attributes.",
                            "type": "string",
                            "indexed": true
                        },
                        "permalink": {
                            "title": "Permalink",
                            "description": "Page permalink, e.g. '/about'.",
                            "type": "string",
                            "indexed": true
                        },
                        "documentId": {
                            "title": "Document ID",
                            "description": "Reference to page content document.",
                            "type": "string"
                        }
                    },
                    "additionalProperties": false,
                    "required": [
                        "title",
                        "permalink",
                        "documentId"
                    ]
                }
            }
        }
    }
}

Content items

A content item is represents data, which is described by a content type it belongs to.

Get

Retrieve all content items of a content type:

GET /contentTypes/{contentTypeId}/contentItems

Response example:

{
    "value": [{ ... }, { ... }, { ... }],
    "count": 100,
    "nextLink": "/contentTypes/page/contentItems?$skip=15&api-version=2018-06-01-preview"
}

Filtering and ordering:

GET /contentTypes/page/contentItems/about?$filter=contains(title,'about')&$orderby=title

Refer to the OData support section for more details on querying the entities.

Create or update

Manage a content item:

GET,PUT,PATCH,DELETE /contentTypes/{contentTypeId}/contentItems/{contentItemId}

Response example:

{
   "id": "/subscriptions/{subscriptionId}/.../contentItems/about",
   "type": "Microsoft.ApiManagement/service/contentItems",
   "name": "about",
   "properties": {
       "en_us": {
           "title": "About",
           "description": "Short story about the company.",
           "keywords": "company, about",
           "permalink": "/en_us/about",
           "documentId": ".../contentTypes/document/contentItems/{documentId}"
       },
       "ru_ru": {
           "title": "О нас",
           "description": "Наша история.",
           "keywords": "компания, о нас",
           "permalink": "/ru_ru/about",
           "documentId": ".../contentTypes/document/contentItems/{documentId}"
       }
   }
}

OData support

Content management API supports filtering and ordering OData operations.

Filtering

Filter the queried collection by one or more entity properties.

Example:

GET /contentTypes/page/contentItems?$filter=title eq 'about'

More options:

$filter=contains(title,'ab')
$filter=startswith(title,'hom')
$filter=endswith(title,'me')

Ordering

Order the queried collection by an entity property.

Example:

GET /contentTypes/page/contentItems?$orderby=en_us/title desc

Clone this wiki locally