Query for getting content fragment variants as JSON | Community
Skip to main content
Level 3
Jun 21, 2021 12:23 PM UTC
Solved

Query for getting content fragment variants as JSON

Hi,

We are trying to get create products with content fragments. But, each product has its own variants. How can we get as JSON each CF with its variants?

queryMap.put("path", "/content/dam/products"); queryMap.put("type","dam:Asset"); queryMap.put("1_property","jcr:content/@contentFragment"); queryMap.put("1_property.value","true");

With this I am getting only the CF, but not its variants. Thanks!

This post is no longer active and is closed to new replies. Need help? Start a new post to ask your question.
Ritesh_Mittal
Ritesh_MittalAccepted solution
New Participant
Jun 21, 2021 3:50 PM UTC

Hi @ad-engineer ,

 

We have HTTP Asset APIs available for Content Fragment. Let me give you example. if your CF is created under '/content/dam/products' then you can access all the CF inside products folder using below GET call-

 

 

http://<HOST>:<PORT>/api/assets/products.json

 

 

I have created a Simple CF with variant to showcase what I mean.

 

1. Created a new CF under '/content/dam/we-retail' using OOTB CF model.

 

 

2. Created two variations (with different RTE authored) and saved.

3. Now accessing http://localhost:4502/api/assets/we-retail.json is giving me both variants.

 

 

Please watch this video to understand-

https://www.youtube.com/watch?v=wtO_GwZggig

Hope it helps!

Cheers!

3 replies

Nikhil-Kumar
New Participant
Jun 21, 2021 7:13 PM UTC

@ad-engineer  - Try leveraging the Content fragment APIs to get any kind of data of master and it's variations:
 For reference:
https://aemsimplifiedbynikhil.wordpress.com/2020/10/11/content-fragment-as-java-apis/ 

Translate
Ritesh_Mittal
Ritesh_MittalAccepted solution
New Participant
Jun 21, 2021 3:50 PM UTC

Hi @ad-engineer ,

 

We have HTTP Asset APIs available for Content Fragment. Let me give you example. if your CF is created under '/content/dam/products' then you can access all the CF inside products folder using below GET call-

 

 

http://<HOST>:<PORT>/api/assets/products.json

 

 

I have created a Simple CF with variant to showcase what I mean.

 

1. Created a new CF under '/content/dam/we-retail' using OOTB CF model.

 

 

2. Created two variations (with different RTE authored) and saved.

3. Now accessing http://localhost:4502/api/assets/we-retail.json is giving me both variants.

 

 

Please watch this video to understand-

https://www.youtube.com/watch?v=wtO_GwZggig

Hope it helps!

Cheers!

Translate
Bhuwan_B
New Participant
Jun 21, 2021 12:28 PM UTC