Expand my Community achievements bar.

"List all Content Fragments" endpoint does not return proper ETag

Avatar

Level 2

I'm using Sites API to list and delete Content Fragments. In particular:

 

  • 'List all Content Fragments" endpoint to get CFs to delete
  • "Delete a Content Fragment" to delete each CF

For deletion endpoint, there are 2 required params:

 

  • "fragmentId" in path
  • "If-Match" in header

I'm getting values for these params from "List all Content Fragments" response for each CF.

 

Example of GET response:

{
  "items": [
    {
      "path": "<...>",
      "title": "<...>",
      "description": "<...>",
      "id": "1833c3df-1345-4c4d-84d5-211c1cc3cd1f",
      "created": {},
      "modified": {},
      "status": "DRAFT",
      "previewReplicationStatus": "NEVER_PUBLISHED",
      "model": {},
      "validationStatus": [],
      "fields": [],
      "variations": [],
      "tags": [],
      "references": [],
      "fieldTags": [],
      "etag": "\"a6b0c90be2c9222696e83ded059108e7\"",
      "tagsCount": 0
    }
  ]
}

 

Example of DELETE request:

curl -i -X DELETE \
  'https://author-p56105-e395653.adobeaemcloud.com/adobe/sites/cf/fragments/1833c3df-1345-4c4d-84d5-211c1cc3cd1f?unlinkReferences=false' \
  -H 'Authorization: Bearer <MY_JWT>' \
  -H 'If-Match: \"a6b0c90be2c9222696e83ded059108e7\"'

 

As you see, I provide appropriate values for the request, but I'm getting "Precondition Failed" error:

 

{
  "type": "https://api.adobeaemcloud.com/adobe/meta/errors/precondition_failed",
  "title": "Precondition Failed",
  "status": 412,
  "detail": "If-Match header does not match the current ETag of the resource",
  "requestId": "c647d94c-a91d-4be5-87a6-e52154f9c365"
}

 

What's the reason of such behavior? Why API returns not valid ETag value? How can I delete CF?

 

Notes

  • As for today, getting individual CF ("Get a Content Fragment" endpoint) does not return `etag` at all
  • ETag value from "List all Content Fragments" endpoint contains double quotes inside it (see my code snippet above) - is it expected?
Topics

Topics help categorize Community content and increase your ability to discover relevant content.

11 Replies

Avatar

Employee

@AMahdzich_Bayer which AEMaaCS Release are you currently using?
This issue may have been addressed in one of the recent releases.

Avatar

Community Advisor

Hi @AMahdzich_Bayer ,

Please refer to this post https://experienceleaguecommunities.adobe.com/t5/adobe-experience-manager-ideas/enhance-openapi-cont...

 

I faced the same problem last year. Recently it started working. And I realized couple gotchas.

Works: etags are returned only for fragments created using 

  1. CF Open API -  https://developer.adobe.com/experience-cloud/experience-manager-apis/api/experimental/sites/ 
  2. From the new CF console 
  3. Using FragmentTemplate java API FragmentTemplate.createFragment.

Fails: It didnt work when I create  

  1. directly using ResourceManager.create as sling resources. Creating individual nodes
  2. using the CF Asset API - https://experienceleague.adobe.com/en/docs/experience-manager-65/content/assets/extending/assets-api...
  3. Using Create Fragment from DAM console. Not using the new CF admin console. 

Some affinity is happening mandating to use the OpenAPI to create fragments. Can you please try creating using OpenAPI and check if Lists API is returning? 

Avatar

Level 2

@muskaanchandwani  how can I check which AEMaaCS Release I'm using?

 

The URL I use to delete CF: `https://<BUCKET>.adobeaemcloud.com/adobe/sites/cf/fragments/<ID>`

 

 

Avatar

Community Advisor and Adobe Champion

@AMahdzich_Bayer, I think you are just using the wrong ETag value in your request. Try to use the ETag value in the If-Match that you received in the response that failed with the precondition error.

c647d94c-a91d-4be5-87a6-e52154f9c365

 

BR,

Daniel

Avatar

Level 2

@daniel-strmecki The value "c647d94c-a91d-4be5-87a6-e52154f9c365" is the Request ID.

According to documentation, "requestId" is

 

A unique identifier that is assigned to the request, either by the API caller or by the service itself.

 

I think ETag should identify the resource version, not API request. Are sure this is correct?

Avatar

Community Advisor and Adobe Champion

Hi @AMahdzich_Bayer,

 

correct, sorry, get the Etag value from the response headers.

 

Good luck,

Daniel

Avatar

Level 2

Hi @daniel-strmecki ,

 

What response headers you mean? I want to make a single list request to get all CFs and delete them afterwards. I don't think there is a response header for the list endpoint ("GET /adobe/sites/cf/fragments") with array of ETAgs.

Avatar

Community Advisor and Adobe Champion

Hi @AMahdzich_Bayer,

yes, but there is also no API to delete CFs in build, AFAIK. So you would need to:

  • Call the "List all Content Fragments" to get all CF IDs

Then loop through them and for each CF:

  • Call the "Get a Content Fragment" to get the Etag value
  • Call the "Delete a Content Fragment" with CF ID and Etag

 

Good luck,

Daniel

Avatar

Level 2

Hi @daniel-strmecki,

 

I see that "List all Content Fragments" returns `etag` field for each CF.

  • Please confirm that this value is not correct.
  • If so, why does API return it at all? It's leading to confusion and I would consider the removal of it.

Avatar

Community Advisor and Adobe Champion

Hi @AMahdzich_Bayer,

if that is the case, it sure sounds like a bug. Please report the issue to Adobe Support.

 

Daniel

Avatar

Level 2