Wednesday, March 29, 2023

Access Content Fragment via API, cURL, Postman, GraphQL in Adobe aem

 








In this article, we will learn how we can access our already-created content fragments via GraphQL. We will also learn how we can fetch, create, update, and delete adobe aem content fragments using postman. we will also learn about how we can access content fragments of adobe aem using cURL in cmd


  • Goto Assets  > GraphQL

  • Click on Create button >  enter project name > select /conf/global  and then create button

  • then you will find the endpoint created.
  • check the endpoint and click on publish 
  • them you will see the endpoint published


Access CF via APIs in Postman


All Content Fragments
  • syntax: http://localhost:4502/api/assets/folder_name
  • Example http://localhost:4502/api/assets/country

Specific Content Fragments
  • syntax: http://localhost:4502/api/assets/folder_name/content_fragment_name.json
  • Example http://localhost:4502/api/assets/country/india.json

 
Post Content Fragments
  • endpoint syntax: http://localhost:4502/api/assets/folder_name/content_fragment_name
  • Example http://localhost:4502/api/assets/country/unitedstate
Body
{
  "properties": {
    "cq:model""/conf/wknd/settings/dam/cfm/models/country-content-model",
    "title""UnitedState",
    "description""UnitedState",
    "elements": {
      "name": {
        "value""UnitedState",
        ":type""text/html",
        "variations": {
          "Urdu": {
            "value": "name in urdu",
            ":type""text/html"
          }
        }
      }
    }
  }
}


Put Content Fragments
  • endpoint syntax: http://localhost:4502/api/assets/folder_name/content_fragment_name
  • Example http://localhost:4502/api/assets/country/india.json

body
{
  "properties": {
    "cq:model""/conf/wknd/settings/dam/cfm/models/country-content-model",
    "title""UnitedStateIndialllll",
    "description""UnitedState",
    "elements": {
      "name": {
        "value""UnitedStatellllll",
        ":type""text/html",
        "variations": {
          "Urdu": {
            "value""<p>name in urdu</p>",
            ":type""text/html"
          }
        }
      }
    }
  }
}


All Content Fragments

  • syntax: http://localhost:4502/api/assets/folder_name/content_fragment_name.json
  • Example: http://localhost:4501/api/assets/country/india.json

Access via cURL in cmd

All Content Fragments
  • Example curl -u admin: admin http://localhost:4502/api/assets/country

Specific Content Fragments
  • Example curl -u admin: admin http://localhost:4502/api/assets/country/india.json
Previous Post
Next Post

post written by:

0 comments: