Display Salesforce CMS Content
Display CMS Content in Experience Builder Sites
Authenticate a Connected App with CMS
Retrieve CMS Channels with a Connected App
Retrieve CMS Content with a Connected App
Search CMS Content with a Connected App
Before you can retrieve CMS content, you need the ID of a CMS channel that has access to the content. Use the Connect REST API’s CMS delivery channels resource to get a list of CMS channels with a connected app. If the request is successful, the response contains a JSON object with the available channels.
To send an API call to get CMS channels, make an HTTP GET request to the /services/data/v{XX.X}/connect/cms/delivery/channels resource.
Include an Authorization header with the value Bearer {access_token}, where access_token is your CMS access token. Optionally, specify the response format with a Content-Type header.
This Node.js sample requests the CMS channels from CMS.
1```javascript
2const auth = require("./sf-crm-auth");
3
4const fetch = require("node-fetch");
5const { URLSearchParams } = require("url");
6
7const url = "/services/data/v54.0/connect/cms/delivery/channels";
8
9module.exports = async function () {
10 const channels = await getChannelsList();
11 return channels.channels;
12};
13
14async function getChannelsList() {
15 return new Promise((resolve, reject) => {
16 auth().then((token) => {
17 const meta = {
18 "Content-Type": "application/json",
19 Authorization: `Bearer ${token.access_token}`,
20 };
21
22 const urlToUse = `${token.instance_url}${url}`;
23 fetch(urlToUse, {
24 method: "GET",
25 headers: meta,
26 })
27 .then((res) => res.json())
28 .then((json) => resolve(json))
29 .catch((err) => {
30 console.log({ err });
31 reject(err);
32 });
33 });
34 });
35}
36```In response to the API request, the API returns an HTTP response code and a JSON body with an object containing the available channels and pagination details.
This sample shows the response body from the previous sample request to retrieve channels.
1{
2 "channels": [
3 {
4 "channelId": "0ap5w000000kcaiAAA",
5 "channelName": "NTO Reference App",
6 "channelType": "ConnectedApp",
7 "isChannelSearchable": true
8 }
9 ],
10 "currentPageUrl": "/services/data/v54.0/connect/cms/delivery/channels?page=0&pageSize=25",
11 "nextPageUrl": null,
12 "previousPageUrl": null,
13 "totalChannels": 1
14}