sample JSON structure to create content fragment using Assets HTTP API | Community
Skip to main content
thatsmeadarsh
Level 3
November 3, 2023
Solved

sample JSON structure to create content fragment using Assets HTTP API

I am trying to create a content fragment with some pre-filled values of content fragment model datatype using Assets API. I am unsure on the format of JSON I need to place in the Body. As per the doc its stating to include the JSON format but it is not working for me. 

Creation of CF is happening with the below JSON

{
"properties": {
"cq:model": "/conf/xxxx/xxx/xxx-headless-portal/settings/dam/cfm/models/sample-model",
"title": "Sample Model",
"description": "Sample model"
}
}
 
But I want to put more properties under the node 'jcr:content/data/master' . How should I structure the JSON? 
 
This post is no longer active and is closed to new replies. Need help? Start a new post to ask your question.
Mahedi_Sabuj
Mahedi_SabujAccepted solution
New Participant
November 7, 2023

Hi @thatsmeadarsh,

You're almost there, need to remove the curly braces `{}` around the element name, changing it from {jsonVal} to jsonVal.

{ "properties": { "cq:model": "/conf/.../settings/dam/cfm/models/sample-model", "title": "Sample Model", "description": "Sample model", "elements": { "jsonVal": { "value": "{}", ":type": "json" } } } }

 

 

Mahedi Sabuj

4 replies

Mahedi_Sabuj
New Participant
November 6, 2023
Mahedi Sabuj
thatsmeadarsh
Level 3
November 7, 2023

Thanks for your response @mahedi_sabuj but unfortunately it seems like I am still missing something. Following the document I created the JSON structure in this way.

 

 

 

{ "properties": { "cq:model": "/conf/xx/xx/xx/settings/dam/cfm/models/sample-model", "title": "Sample Model", "description": "Sample model", "elements": { "{jsonVal}": { "value": "{}", ":type": "json" } } } }

 

My CF model contains only a single Data Type 'Json Object' . The property name of that is 'jsonVal' . After POST operation I get below error "status.message":"Could not update content element","status.code":500}} . It would be helpful if I get the ideal JSON format for this example. Thanks again for your response.

 

Translate
Mahedi_Sabuj
Mahedi_SabujAccepted solution
New Participant
November 7, 2023

Hi @thatsmeadarsh,

You're almost there, need to remove the curly braces `{}` around the element name, changing it from {jsonVal} to jsonVal.

{ "properties": { "cq:model": "/conf/.../settings/dam/cfm/models/sample-model", "title": "Sample Model", "description": "Sample model", "elements": { "jsonVal": { "value": "{}", ":type": "json" } } } }

 

 

Translate
Mahedi Sabuj