Unable Create Content Fragment using post request for Data Type JsonObject | Community
Skip to main content
Level 2
October 9, 2024
Question

Unable Create Content Fragment using post request for Data Type JsonObject

  • October 9, 2024
  • 1 reply
  • 67 views

I am trying to create a content fragment using the post request using /api/assets, it is working fine for all the other Content Fragment Data Type but not for the Data Type JsonObject.

 

Below is the request i am trying and it is not working. But if i pass a single object in my jsonArray, my content fragment is getting created.

Please let me know if there is any other way other than creating a content model and referencing it.

http://localhost:4502/api/assets/project/content-fragments/en_GB/myModel/tesModel

{
   "properties":{
      "cq:model":"/conf/cuk/settings/dam/cfm/models/myModel",
    "elements": {
              "jsonObject" : {
            "value" :  [
              {
                "name" : "Name 1"
               },
              {
                    "name" : "Name 2"
              }
              ],
            ":type" : "string"
             }
       }
  }
}
 

 

 

This post is no longer active and is closed to new replies. Need help? Start a new post to ask your question.

1 reply

Level 2
October 11, 2024

Got one more solution just by changing the valueType to "json[]" it works and we are going with this approach.

<jsonObject
jcr:primaryType="nt:unstructured"
sling:resourceType="dam/cfm/admin/components/authoring/contenteditor/jsoneditor"
cfm-element="Json Object"
listOrder="13"
metaType="json"
name="jsonObject"
renderReadOnly="false"
showEmptyInReadOnly="true"
valueType="json[]"/>