Five New Optimizely Certifications are Here! Validate your expertise and advance your career with our latest certification exams. Click here to find out more

Issue with Content Management API: Handling RichTextEditor Block and Property Types

Vote:
 

Hi,

I am implementing Content Management API in my Optimizely solution and have successfully completed the initial setup without authentication as a starting point.

I am trying to add a block of type RichTextEditor, which has the following required property:

[Required(AllowEmptyStrings = false)]
[Display(GroupName = SystemTabNames.Content, Name = "Rich Text Content Area", Description = "Add text content area here")]
[CultureSpecific]
public virtual XhtmlString ContentArea { get; set; }

However, when attempting to create this block using the Content Management API, I receive the following error:

{
  "type": "https://tools.ietf.org/html/rfc7231#section-6.5.1",
  "title": "Bad Request",
  "status": 400,
  "detail": "Error reading string. Unexpected token: StartObject. Path 'value'.",
  "instance": "/api/episerver/v3.0/contentmanagement",
  "code": "InvalidPropertyValue",
  "traceId": "00-8bad783970639cb7e1ddc9ffa0c8ddf4-664c4166a616948e-00"
}
 

Here is my JSON request to create the RichTextEditor block:

{
  "name": "Text Block (Content Management API)",
  "language": {
    "name": "en"
  },
  "contentType": [
    "Block",
    "RichTextEditorBlock"
  ],
  "parentLink": {
    "id": "3"
  },
  "contentArea": {
    "value": "<p>Hello World</p>"
  },
  "status": "Published"
}
 

When I remove the ContentArea property, I am able to create the block with an empty content area successfully.

I have reviewed the documentation, but it only specifies the CRUD operations API calls:
Optimizely Content Management API Docs

So, my questions are:

1- How should I correctly pass properties of different types (e.g., XhtmlString, Url, Media, etc.) in the API request? Is there any documentation outlining how to pass various property types?

2- I have found multiple forum discussions on obtaining a token, with different URLs provided in each. One of them is shown below:

/episerverapi/token

I tried the above approach to obtain a token, but it returns the UI instead of the token. Could someone please point me in the right direction to retrieve the token before making the CRUD operation to save content in Optimizely?

 

It's basically I get the website UI as response when trying to get Token in Postman:

Regards.

 

#337022
Edited, Feb 26, 2025 22:17
Vote:
 

Hi,
Could you share the UI that you got when getting api token?

#337148
Mar 09, 2025 9:05
Farhin - Mar 10, 2025 15:55
Hello Binh Nguyen. I updated the question with screenshot of the response which is just the UI that I get in response to calling api token. I even tried ....../episerverapi/token as url but the response is same .It returns me UI rather than token.
* You are NOT allowed to include any hyperlinks in the post because your account hasn't associated to your company. User profile should be updated.