Create a CMS Section
Creates a CMS Section
POST
/
api
/
v2
/
platform
/
cms_sections
Create a CMS Section
const options = {
method: 'POST',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({
cms_section: {
name: '<string>',
cms_page_id: '<string>',
type: 'Spree::Cms::Sections::HeroImage',
linked_resource_type: 'Spree::Taxon',
linked_resource_id: '1',
fit: 'Screen',
position: 2,
gutters: 'No Gutters',
button_text: 'Click Here',
title: 'Shop Today',
'cms_section[image_one]': '<string>'
}
})
};
fetch('http://{defaultHost}/api/v2/platform/cms_sections', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));curl --request POST \
--url http://{defaultHost}/api/v2/platform/cms_sections \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"cms_section": {
"name": "<string>",
"cms_page_id": "<string>",
"type": "Spree::Cms::Sections::HeroImage",
"linked_resource_type": "Spree::Taxon",
"linked_resource_id": "1",
"fit": "Screen",
"position": 2,
"gutters": "No Gutters",
"button_text": "Click Here",
"title": "Shop Today",
"cms_section[image_one]": "<string>"
}
}
'{
"data": {
"id": "13",
"type": "cms_section",
"attributes": {
"name": "Hic iste cupiditate corrupti esse minima.",
"content": {},
"settings": {
"gutters": "No Gutters"
},
"fit": "Screen",
"destination": null,
"type": "Spree::Cms::Sections::HeroImage",
"position": 3,
"linked_resource_type": "Spree::Product",
"created_at": "2022-11-08T19:34:04.185Z",
"updated_at": "2022-11-08T19:34:04.185Z"
},
"relationships": {
"cms_page": {
"data": {
"id": "15",
"type": "cms_page"
}
},
"linked_resource": {
"data": {
"id": "23",
"type": "product"
}
}
}
}
}{
"error": "Name can't be blank, Cms page can't be blank, and Type can't be blank",
"errors": {
"name": [
"can't be blank"
],
"cms_page": [
"can't be blank"
],
"type": [
"can't be blank"
]
}
}Authorizations
Bearer authentication header of the form Bearer <token>, where <token> is your auth token.
Query Parameters
Select which associated resources you would like to fetch, see: https://jsonapi.org/format/#fetching-includes
Body
application/json
- Create a Hero Image Section
- Create a Product Carousel Section
- Create a Side-by-Side Image Section
- Create a Featured Article Section
- Create an Image Gallery Section
- Create a Rich Text Section
Show child attributes
Show child attributes
Response
Record created
Show child attributes
Show child attributes
Was this page helpful?
⌘I
Create a CMS Section
const options = {
method: 'POST',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({
cms_section: {
name: '<string>',
cms_page_id: '<string>',
type: 'Spree::Cms::Sections::HeroImage',
linked_resource_type: 'Spree::Taxon',
linked_resource_id: '1',
fit: 'Screen',
position: 2,
gutters: 'No Gutters',
button_text: 'Click Here',
title: 'Shop Today',
'cms_section[image_one]': '<string>'
}
})
};
fetch('http://{defaultHost}/api/v2/platform/cms_sections', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));curl --request POST \
--url http://{defaultHost}/api/v2/platform/cms_sections \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"cms_section": {
"name": "<string>",
"cms_page_id": "<string>",
"type": "Spree::Cms::Sections::HeroImage",
"linked_resource_type": "Spree::Taxon",
"linked_resource_id": "1",
"fit": "Screen",
"position": 2,
"gutters": "No Gutters",
"button_text": "Click Here",
"title": "Shop Today",
"cms_section[image_one]": "<string>"
}
}
'{
"data": {
"id": "13",
"type": "cms_section",
"attributes": {
"name": "Hic iste cupiditate corrupti esse minima.",
"content": {},
"settings": {
"gutters": "No Gutters"
},
"fit": "Screen",
"destination": null,
"type": "Spree::Cms::Sections::HeroImage",
"position": 3,
"linked_resource_type": "Spree::Product",
"created_at": "2022-11-08T19:34:04.185Z",
"updated_at": "2022-11-08T19:34:04.185Z"
},
"relationships": {
"cms_page": {
"data": {
"id": "15",
"type": "cms_page"
}
},
"linked_resource": {
"data": {
"id": "23",
"type": "product"
}
}
}
}
}{
"error": "Name can't be blank, Cms page can't be blank, and Type can't be blank",
"errors": {
"name": [
"can't be blank"
],
"cms_page": [
"can't be blank"
],
"type": [
"can't be blank"
]
}
}
