LoginSignup
0
0

CMS Enhanced Workspace にアクセスできない

Last updated at Posted at 2024-01-24

調べてみると散見されるけど、解決策は分からないです

API接続

/connect/cms/delivery/channels/channelId/contents/query
[
  {
    "errorCode": "INSUFFICIENT_ACCESS",
    "message": "You don't have access to this channel."
  }
]

[{"message":"An unexpected error occurred. Please include this ErrorId if you contact support: 1372070177-81040 (-89852554)","errorCode":"UNKNOWN_EXCEPTION"}]

ドキュメントでは、リクエスト本文のサンプルは次のとおりです。

{
"contentSpaceOrFolderId":"0Zuxx00000003M5CAI",
"title":"Title of Document",
"contentType":"ftestSfdcOnly__banner",
"urlName":"testUrl",
"contentBody" : {
   "bannerImage":"MCZOCY2AM5PFBADN5UDRB53TLXR4",
   "featuredEvent":"MCZOCY2AM5PFBADN5UDRB53TLXR4",
   "excerpt":"this is test except",
   "body":"<p>Test body</p>"
   }
}

このリクエスト本文は失敗します。ただし、次のリクエスト本文は機能するようです。基本的に、REST API からコンテンツを要求したときに受信されるものと同様の画像参照の構造が必要です。上記を調整すると:

{
"contentSpaceOrFolderId":"0Zuxx00000003M5CAI",
"title":"Title of Document",
"contentType":"ftestSfdcOnly__banner",
"urlName":"testUrl",
"contentBody" : {
   "bannerImage": { "source": { "type": "imageReference", "ref": { "contentKey": "MCZOCY2AM5PFBADN5UDRB53TLXR4" } } },
   "featuredEvent": { "source": { "type": "imageReference", "ref": { "contentKey": "MCZOCY2AM5PFBADN5UDRB53TLXR4" } } },
   "excerpt":"this is test except",
   "body":"<p>Test body</p>"
   }
}

LWR

これがベストアンサーだけど、具体的なところは分からん

ConnectAPI.ManagedContent は、通常のワークスペース API です。拡張ワークスペース (およびチャネル) の場合、クラスは ConnectAPI.ManatedContentdelivery です。

ConnectAPI.ManagedContent is our regular workspace APIs. For enhanced workspaces (and channels), the class is ConnectAPI.ManagedContentDelivery. Here is a list: ManagedContentDelivery Class | Apex Reference Guide | Salesforce

LWR サイトのカスタム URL パスが疑われているけど...

Aura サイトとは異なり、Experience Cloud の LWR サイトはカスタム URL パスをサポートしているため、サイトの URL (例: https://mycustomdomain.com/mypage )に/sが混入する必要がなくなります。
Winter '23 より前では、認証済みまたは非認証の LWR サイトを作成できました。認証されていないサイトはカスタム URL パスをサポートしていましたが、認証されたサイトには ベース URL の末尾に /sが含まれていました (例: https://mycustomdomain.com/s/mypage )。

Winter '23 以降で作成された LWR サイトでは、URL に/s が含まれなくなり、デフォルトで認証されたサイトになります。認証されたサイトでは、ユーザーはログインしてユーザー固有のデータにアクセスできますが、公開ページを含めたり、サイト全体を公開してアクセスできるようにすることもできます。

拡張および非拡張 CMS ワークスペースの CMS コンテンツを任意の拡張 LWR サイトと共有できるようになりました。以前は、拡張 CMS ワークスペースのコンテンツは拡張 LWR サイトとしか共有できませんでした。

サイト アクセスできる CMS コンテンツの共有元
拡張 LWR サイト 拡張 CMS ワークスペースまたは CMS ワークスペース
LWR サイト CMS ワークスペース
Aura サイト CMS ワークスペース

拡張 LWR サイトとは?
機能強化された LWR サイトでは、部分的なリリースが可能になり、可動する準備が整ったサイト要素を選択できます。サイトコンテンツ検索では、リッチコンテンツエディターと HTML エディターコンポーネントのコンテンツを検索できます。すべての要素が統合されたプラットフォーム上で実行されるため、サイト検索には、拡張 CMS ワークスペースから共有するコンテンツも含めることができます。


HTML

<template>
     <div>   
        <img src={imageUrl} data-contentkey={imageUrl} class="image imgFilter imgColor" style={componentStyle}></img>    
    </div>   
</template>

Salesforce CMS コンテンツ (管理コンテンツオブジェクト) を操作し、Apex を使用してコンテンツを取得しようとしている場合、getManagedContentByContentKeys や getManagedContentByIds などの ManagedContent クラスのメソッドを利用すると、このエラーが発生する場合があります。

When working with Salesforce CMS Content (Managed Content Object) and attempting to retrieve content using Apex, you may encounter this error when utilizing methods from the ManagedContent class methods such as getManagedContentByContentKeys or getManagedContentByIds

ConnectApi.ConnectApiException:[errorCode=INSUFFICIENT_ACCESS]: "You don't have access to this channel."

This error occurs because of the ConnectAPI.ManagedContent is designed for regular workspace APIs. For enhanced workspaces (and channels), you should use the ConnectAPI.ManagedContentDelivery class instead.

Here's an example of Lightning Web Components (LWC) to display CMS Content (Collection) as an accordion on a public Lightning Web Runtime (LWR) site, leveraging the ConnectAPI.ManagedContentDelivery class.

https://sfcrunch.com/salesforce-lwc-to-show-cms-content-collection-as-accordion-on-public-lwr-site-using-connectapi-managedcontentdelivery-class/

このエラーは、ConnectAPI.ManagedContent が通常のワークスペース API 用に設計されているために発生します。拡張されたワークスペース (およびチャネル) の場合は、代わりに ConnectAPI.ManagedContentdelivery クラスを使用する必要があります。

ConnectAPI.ManagedContentdelivery クラスを利用して、パブリック Lightning Web ランタイム (LWR) サイト上で CMS コンテンツ (コレクション) をアコーディオンとして表示する Lightning Web コンポーネント (LWC) の例を次に示します。

Indeed, not possible out of the box yet. Here's the info from Salesforce support :

I understand your issue regarding the "Unable to export content of Enhanced CMS Workspace"

The import/export functionality is not currently available out of the box for Enhanced CMS Workspaces.

Authoring APIs are available to retrieve and create single content, but there is no bulk API available at the moment. One thing to note is that you can't insert the retrieved content directly as it has a few derived properties which need to be removed from the input payload via manual transformation. Following article lists all the public APIs which are available for the enhanced workspace. You should be able to retrieve and import content using the "Create managed content" API with some manual transformation. If you compare the payload for "Create managed content" and "Get or update a managed content variant" APIs, you will be able to find what transformation is needed.

Documentation : https://developer.salesforce.com/docs/atlas.en-us.chatterapi.meta/chatterapi/connect_resources_managed_content_enhanced_resources.htm

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0