Message Boards
Headless Delivery API - Create Structure Content in a Folder
Headless Delivery API - Create Structure Content in a Folder
New Member Posts: 5 Join Date: 11/16/20 Recent PostsHello,
I am trying to use the Headless Delivery API 1.0 for creating Structure Content in a specific Folder.
Here is a GET response:
{
"actions": {
"get": {
"method": "GET",
"href": "http://localhost:8080/o/headless-delivery/v1.0/structured-content-folders/{structuredContentFolderId}/structured-contents"
},
"create": {
"method": "POST",
"href": "http://localhost:8080/o/headless-delivery/v1.0/structured-content-folders/{structuredContentFolderId}/structured-contents"
}
},
"facets": [],
"items": [
{
"actions": {
"get-rendered-content": {
"method": "GET",
"href": "http://localhost:8080/o/headless-delivery/v1.0/structured-contents/{structuredContentId}/rendered-content/{contentTemplateId}"
},
"subscribe": {
"method": "PUT",
"href": "http://localhost:8080/o/headless-delivery/v1.0/structured-contents/{structuredContentId}/subscribe"
},
"unsubscribe": {
"method": "PUT",
"href": "http://localhost:8080/o/headless-delivery/v1.0/structured-contents/{structuredContentId}/unsubscribe"
},
"get": {
"method": "GET",
"href": "http://localhost:8080/o/headless-delivery/v1.0/structured-contents/{structuredContentId}"
},
"replace": {
"method": "PUT",
"href": "http://localhost:8080/o/headless-delivery/v1.0/structured-contents/{structuredContentId}"
},
"update": {
"method": "PATCH",
"href": "http://localhost:8080/o/headless-delivery/v1.0/structured-contents/{structuredContentId}"
},
"delete": {
"method": "DELETE",
"href": "http://localhost:8080/o/headless-delivery/v1.0/structured-contents/{structuredContentId}"
}
},
"availableLanguages": [
"en-US"
],
"contentFields": [
{
"contentFieldValue": {},
"dataType": "",
"label": "Content Information",
"name": "ContentInformation",
"nestedContentFields": [
{
"contentFieldValue": {
"data": "OFF001"
},
"dataType": "string",
"inputControl": "text",
"label": "Content Code",
"name": "ContentCode",
"nestedContentFields": [],
"repeatable": false
},
{
"contentFieldValue": {
"data": "Offer 1 for Huawei"
},
"dataType": "string",
"inputControl": "text",
"label": "Content Description",
"name": "ContentDescription",
"nestedContentFields": [],
"repeatable": false
},
{
"contentFieldValue": {
"data": "[\"offer\"]"
},
"dataType": "string",
"inputControl": "select",
"label": "Content Type",
"name": "ContentType",
"nestedContentFields": [],
"repeatable": false
}
],
"repeatable": false
},
{
"contentFieldValue": {},
"dataType": "",
"label": "Resource",
"name": "Resource",
"nestedContentFields": [
{
"contentFieldValue": {
"document": {
"contentType": "Document",
"contentUrl": "/documents/20121/38282/Test+Huawei+Cover.jpg/1802157f-e6fa-02db-4473-1ed962e65be3?t=1611052861115",
"description": "Test",
"encodingFormat": "image/jpeg",
"fileExtension": "jpg",
"id": 38293,
"sizeInBytes": 51726,
"title": "Test Huawei Cover"
}
},
"dataType": "document",
"label": "Huawei Resource",
"name": "HuaweiResource",
"nestedContentFields": [
{
"contentFieldValue": {
"data": "[\"web\"]"
},
"dataType": "string",
"inputControl": "select",
"label": "Channel",
"name": "Channel",
"nestedContentFields": [],
"repeatable": false
},
{
"contentFieldValue": {
"data": "[\"list\"]"
},
"dataType": "string",
"inputControl": "select",
"label": "Located",
"name": "Located",
"nestedContentFields": [],
"repeatable": false
}
],
"repeatable": false
}
],
"repeatable": true
},
{
"contentFieldValue": {},
"dataType": "",
"label": "Resource",
"name": "Resource",
"nestedContentFields": [
{
"contentFieldValue": {
"document": {
"contentType": "Document",
"contentUrl": "/documents/20121/38282/Test+Huawei+P30+Lite.jpg/eac3c035-0cbf-1135-c2ee-9c65746e02ae?t=1611052802311",
"description": "Test",
"encodingFormat": "image/jpeg",
"fileExtension": "jpg",
"id": 38303,
"sizeInBytes": 20747,
"title": "Test Huawei P30 Lite"
}
},
"dataType": "document",
"label": "Huawei Resource",
"name": "HuaweiResource",
"nestedContentFields": [
{
"contentFieldValue": {
"data": "[\"mobile\"]"
},
"dataType": "string",
"inputControl": "select",
"label": "Channel",
"name": "Channel",
"nestedContentFields": [],
"repeatable": false
},
{
"contentFieldValue": {
"data": "[\"list\"]"
},
"dataType": "string",
"inputControl": "select",
"label": "Located",
"name": "Located",
"nestedContentFields": [],
"repeatable": false
}
],
"repeatable": false
}
],
"repeatable": true
},
{
"contentFieldValue": {},
"dataType": "",
"label": "Resource",
"name": "Resource",
"nestedContentFields": [
{
"contentFieldValue": {
"document": {
"contentType": "Document",
"contentUrl": "/documents/20121/38279/HTML+for+P20/cbf5efc8-ee11-c23a-b3a4-0a0884a9476b?t=1611669428021",
"description": "P20",
"encodingFormat": "application/octet-stream",
"fileExtension": "",
"id": 38323,
"sizeInBytes": 0,
"title": "HTML for P20"
}
},
"dataType": "document",
"label": "Huawei Resource",
"name": "HuaweiResource",
"nestedContentFields": [
{
"contentFieldValue": {
"data": "[\"web\"]"
},
"dataType": "string",
"inputControl": "select",
"label": "Channel",
"name": "Channel",
"nestedContentFields": [],
"repeatable": false
},
{
"contentFieldValue": {
"data": "[\"detail\"]"
},
"dataType": "string",
"inputControl": "select",
"label": "Located",
"name": "Located",
"nestedContentFields": [],
"repeatable": false
}
],
"repeatable": false
}
],
"repeatable": true
}
],
"contentStructureId": 38361,
"creator": {
"additionalName": "",
"contentType": "UserAccount",
"familyName": "Test",
"givenName": "Test",
"id": 20125,
"name": "Test Test"
},
"customFields": [],
"dateCreated": "2021-01-18T16:37:17Z",
"dateModified": "2021-01-21T16:09:22Z",
"datePublished": "2021-01-18T16:36:00Z",
"description": "",
"friendlyUrlPath": "offer-001-test",
"id": 38837,
"key": "38835",
"keywords": [],
"numberOfComments": 0,
"relatedContents": [],
"renderedContents": [],
"siteId": 20121,
"subscribed": false,
"taxonomyCategoryBriefs": [],
"title": "Offer 001 Test",
"uuid": "a2e99c53-3a9b-3c79-994b-2b55b2cf54f1"
}
],
"lastPage": 1,
"page": 1,
"pageSize": 20,
"totalCount": 1
}
Here is a POST request (Body) I am trying to use:
{
"contentFields":[
{
"name":"ContentInformation",
"nestedContentFields":[
{
"contentFieldValue":{
"data":"OFF001"
},
"name":"ContentCode"
},
{
"contentFieldValue":{
"data":"Offer 1 for Huawei"
},
"name":"ContentDescription"
},
{
"contentFieldValue":{
"data":"offer"
},
"name":"ContentType"
}
]
},
{
"name":"Resource",
"nestedContentFields":[
{
"contentFieldValue":{
"document":{
"id":38293
}
},
"name":"HuaweiResource",
"nestedContentFields":[
{
"contentFieldValue":{
"data":"web"
},
"name":"Channel"
},
{
"contentFieldValue":{
"data":"list"
},
"name":"Located"
}
]
}
]
},
{
"name":"Resource",
"nestedContentFields":[
{
"contentFieldValue":{
"document":{
"id":38303
}
},
"name":"HuaweiResource",
"nestedContentFields":[
{
"contentFieldValue":{
"data":"mobile"
},
"name":"Channel"
},
{
"contentFieldValue":{
"data":"list"
},
"name":"Located"
}
]
}
]
},
{
"contentFieldValue":{
},
"name":"Resource",
"nestedContentFields":[
{
"contentFieldValue":{
"document":{
"id":38323
}
},
"name":"HuaweiResource",
"nestedContentFields":[
{
"contentFieldValue":{
"data":"web"
},
"name":"Channel"
},
{
"contentFieldValue":{
"data":"detail"
},
"name":"Located"
}
]
}
]
}
],
"contentStructureId": 38361,
"title":"Offer 001 Test API"
}
I am facing an infinite loop between:
- No value is specified for field ContentInformation
- Value should not be set for transient field name ContentInformation
ContentInformation is just a ddm-separator with form fields nested inside, so I do not want to send a value with it. If I send a value then it complains I am sending a value.
How can I create Structure Content with Nested Fields?
RE: Headless Delivery API - Create Structure Content in a Folder
New Member Posts: 5 Join Date: 11/16/20 Recent PostsThis is the Structure Content definition:
{
"availableLanguages": [
"ar-SA",
"en-US"
],
"contentStructureFields": [
{
"dataType": "",
"label": "Content Information",
"localizable": true,
"multiple": false,
"name": "ContentInformation",
"nestedContentStructureFields": [
{
"dataType": "string",
"inputControl": "text",
"label": "Content Code",
"localizable": false,
"multiple": false,
"name": "ContentCode",
"nestedContentStructureFields": [],
"options": [],
"predefinedValue": "",
"repeatable": false,
"required": false,
"showLabel": true
},
{
"dataType": "string",
"inputControl": "text",
"label": "Content Description",
"localizable": true,
"multiple": false,
"name": "ContentDescription",
"nestedContentStructureFields": [],
"options": [],
"predefinedValue": "",
"repeatable": false,
"required": false,
"showLabel": true
},
{
"dataType": "string",
"inputControl": "select",
"label": "Content Type",
"localizable": false,
"multiple": false,
"name": "ContentType",
"nestedContentStructureFields": [],
"options": [
{
"label": "Offer",
"value": "offer"
},
{
"label": "Sales Catalog",
"value": "sales-catalog"
},
{
"label": "FAQ",
"value": "FAQ"
},
{
"label": "Agreement",
"value": "agreement"
}
],
"predefinedValue": "[\"\"]",
"repeatable": false,
"required": false,
"showLabel": true
}
],
"options": [],
"predefinedValue": "",
"repeatable": false,
"required": false,
"showLabel": true
},
{
"dataType": "",
"label": "Resource",
"localizable": true,
"multiple": false,
"name": "Resource",
"nestedContentStructureFields": [
{
"dataType": "document",
"label": "Huawei Resource",
"localizable": true,
"multiple": false,
"name": "HuaweiResource",
"nestedContentStructureFields": [
{
"dataType": "string",
"inputControl": "select",
"label": "Channel",
"localizable": false,
"multiple": false,
"name": "Channel",
"nestedContentStructureFields": [],
"options": [
{
"label": "Mobile",
"value": "mobile"
},
{
"label": "Web",
"value": "web"
}
],
"predefinedValue": "[\"\"]",
"repeatable": false,
"required": false,
"showLabel": true
},
{
"dataType": "string",
"inputControl": "select",
"label": "Located",
"localizable": false,
"multiple": false,
"name": "Located",
"nestedContentStructureFields": [],
"options": [
{
"label": "List",
"value": "list"
},
{
"label": "Detail",
"value": "detail"
},
{
"label": "Home",
"value": "home"
}
],
"predefinedValue": "[\"home\"]",
"repeatable": false,
"required": false,
"showLabel": true
}
],
"options": [],
"predefinedValue": "",
"repeatable": false,
"required": false,
"showLabel": true
}
],
"options": [],
"predefinedValue": "",
"repeatable": true,
"required": false,
"showLabel": true
}
],
"creator": {
"additionalName": "",
"contentType": "UserAccount",
"familyName": "Test",
"givenName": "Test",
"id": 20125,
"name": "Test Test"
},
"dateCreated": "2021-01-13T13:06:41Z",
"dateModified": "2021-01-21T14:05:52Z",
"description": "Huawei Content along with Huawei Resources",
"id": 38361,
"name": "Huawei Content",
"siteId": 20121
}
And this is a Screenshot of the Structure rendered in Edit Mode
RE: Headless Delivery API - Create Structure Content in a Folder
Expert Posts: 348 Join Date: 2/12/15 Recent PostsThe issue is the extra fields group, if you just use the default one (and separators, those should be supported) it should work fine. So it's a bug with the management of several field groups, I've created a ticket here: https://issues.liferay.com/browse/LPS-129105 and sent a fix.
Which version are you using?
PD: Sorry for the delay, the message slipped through the cracks.
RE: RE: Headless Delivery API - Create Structure Content in a Folder
New Member Posts: 5 Join Date: 11/16/20 Recent PostsThanks Javier for the answer
It is Liferay 7.3.5 CE Edition
Kind regards.
RE: RE: Headless Delivery API - Create Structure Content in a Folder
Expert Posts: 348 Join Date: 2/12/15 Recent PostsOk, I've backported the fix so it'll be available in the next fixpacks