Is the Content Block (498) of the correct type (Hero Block)?
Have you also tried disabling the validation ?
Header: x-epi-validation-mode
Value: minimal
Thanks for the reply Minesh.
The content block is indeed the correct type.
The x-epi-validation-mode header trick did not work for me, but thanks for the idea!
Fredrik Larsson suggested:
"ContentArea": [ { "contentLink": { "id": 1270, "workId": 0, "guidValue": "a1fb0627-2709-4de2-9bea-12b246c6fabc", "type": 0 } }] // OR "ContentArea": [ { "contentLink": { "id": 1270, "workId": 0, "guidValue": "a1fb0627-2709-4de2-9bea-12b246c6fabc", "type": "Normal" } }]
but that didn't work for me, either! Here's a link to the slack thread: https://optimizely-community.slack.com/archives/C01UW3RT8KC/p1674824705498919?thread_ts=1674818946.525209&cid=C01UW3RT8KC
The most excellent Tuan from the Application Support Team sent me this:
Below is the sample to:
Creating block
{
"contentLink": {
"guidValue": "ca5aa43d-20f1-4992-9f1b-1cacbd7eda27"
},
"name": "Beach Hero",
"language": {
"name": "en"
},
"contentType": [
"Block",
"HeroBlock"
],
"parentLink": {
"id": 3
},
"status": "Published"
}
Using block on content area where 623 is the new block created above - Patch
{
"mainContentArea": {
"value": [
{
"displayOption": "",
"contentLink": {
"id": 174,
"workId": 0,
"guidValue": "43212acb-0e1b-4328-9d66-ef138db05380"
}
},
{
"displayOption": "half",
"contentLink": {
"id": 117,
"workId": 0,
"guidValue": "4faa829a-7cdb-4b88-9b25-c947d8fa66db"
}
},
{
"displayOption": "half",
"contentLink": {
"id": 119,
"workId": 0,
"guidValue": "2a610715-aef8-4890-bd5d-64369f264cf8"
}
},
{
"displayOption": "",
"contentLink": {
"id": 177,
"workId": 0,
"guidValue": "e7ad15e5-ddc1-4040-85e4-3821ae4bbe03"
}
},
{
"displayOption": "",
"contentLink": {
"id": 623,
"workId": 0
}
}
],
"propertyDataType": "PropertyContentArea"
}
}
And Vlad sent me this:
I played a bit with empty installation, have it working with values like this – can you give it a try? Notice “value” and “contentLink” things inside:
"herocontentarea": {
"value": [{
"contentLink": {
"id": 498
}
}]
},
I noted that both suggestions had an array of contentLinks inside the value obj inside the content area. This didn't work for us... but maybe it's because we have customized the API somewhat.
Here's what DID work for us:
{
"name": "content management created page",
"language": {
"name": "en"
},
"parentLink": {
"id": 112
},
"contentType": [
"StandardPage"
],
"pageTitle": "content management created page title",
"SeoDescription": "Some SeoDescription",
"BrowserTitle": "Some title",
"herocontentarea": [ {
"contentLink": {
"id": 204,
}
}],
"contentarea1":[ {
"contentLink": {
"id": 134,
"type": 0
}
}],
"status": "Published"
}
Note that I'm missing the 'value' obj. I'm not sure if this works because of our customizations, so don't take this as a solve. But if it helps you please do let me know!
It turns out that our custom converters had caused a hard fail with some internal EPi function during block assignment to a page! Once again, Vlad V. comes to the rescue by mentioning the magical IExcludeFromModelTypeRegistration. We applied it to our underlying model where we saw the error, and now we can use the Content Management API to create Pages and Blocks, and put the Blocks into the Pages!
Use the interface like so:
public class SuperContentAreaPropertyModel : ContentAreaPropertyModel, IExcludeFromModelTypeRegistration
{
...
}
Hi,
We are using the v3.6 of the Content management API. I’m getting the following error:
{
"type": https://tools.ietf.org/html/rfc7231#section-6.5.1,
"title": "Bad Request",
"status": 400,
"detail": "Value cannot be null. (Parameter 'type')",
"instance": "/api/episerver/v3.0/contentmanagement/c53d26a2-7055-4fd4-844d-aef596f3cf73",
"code": "InvalidPropertyValue",
"traceId": "00-620caf37a1ad41d59faa3e40dba9b425-025ff0779a52fccf-00"
}
… caused by this JSON:
{
"name": "content management created page",
"parentLink": {
"id": 112
},
"contentType": [
"StandardPage"
],
"herocontentarea": [ {
"id": 498,
"workId": 0,
"guidValue": "e43766c5-32d3-4876-ab38-da7005970b5b",
}],
"status": "Published"
}
I’m not sure what ‘type’ parameter the error is referring to. The error only appears when trying to update the ‘herocontentarea’ property. I am able to update other, simpler properties such as strings using the API.
[CultureSpecific]
[AllowedTypes(typeof(HeroBlock))]
[Display(GroupName = PropertyGroupNames.Content, Order = 20)]
public virtual ContentArea HeroContentArea { get; set; }
We are able to update the HeroContentArea manually using the admin UI just fine. However, I can’t get the management API to accept the update.
I’ve been referencing: Content Management API | Optimizely Developer Community
Cheers,
Lance