Expand my Community achievements bar.

SOLVED

Adobe Assets API, when creating a content fragment, how do I add a Multiple Field (single line text) in the body properly?

Avatar

Level 2

Creating a content fragment programmatically, it is successful apart from the creation of a multi-field where i

Using this as a reference:
https://developer.adobe.com/experience-manager/reference-materials/6-5/assets-api-content-fragments/...


How can I input a multi field text? as seen below:

The data type is 'single line text', and it renders as 'Multiple Field' in my content fragment model. 

 

mvotos_0-1708542457296.png

 

for instance a single field is just:

"{elementName}": {        
"value": "<p>The HTML content of the element.</p>",
":type": "text/html",

 

How would a multiple field text look like if sending a POST? That is dynamic for the size, such as the number of inputs or elements within.

I currently have it looking like this:

 

"habitat": {
"value": JSON.stringify(test),
":type": "application/json"
},
Where test is an array of form inputs, except it ends up being in the same row, rather than each input taking up 1 field.

 

So it looks like 'Test1, Test2, Test3' on the same field, rather than:

  1. Test1
  2. Test2
  3. Test3

each being its own field

  

1 Accepted Solution

Avatar

Correct answer by
Community Advisor

Hi, 

You just need to append the values in the "value" field. Something like below:

{
  "properties": {
    "cq:model": "/conf/myFolderToCF/settings/dam/cfm/models/demotest",
    "title": "my content fragment from postman",
    "description": "my test",
    "elements": {
      "myTextFieldName": {
        ":type": "string",
        "value": [
                    "1",
                    "2",
                    "3"
                ]
      }
    }
  }
}

EstebanBustamante_0-1708545547746.png

 

The trick is to first GET a created CF using the Assets API and check how the values are being stored.

 

Hope this helps.



Esteban Bustamante

View solution in original post

1 Reply

Avatar

Correct answer by
Community Advisor

Hi, 

You just need to append the values in the "value" field. Something like below:

{
  "properties": {
    "cq:model": "/conf/myFolderToCF/settings/dam/cfm/models/demotest",
    "title": "my content fragment from postman",
    "description": "my test",
    "elements": {
      "myTextFieldName": {
        ":type": "string",
        "value": [
                    "1",
                    "2",
                    "3"
                ]
      }
    }
  }
}

EstebanBustamante_0-1708545547746.png

 

The trick is to first GET a created CF using the Assets API and check how the values are being stored.

 

Hope this helps.



Esteban Bustamante