I'm using the following curl command to make changes into the content fragment through curl.
curl -i -X PATCH \ 'https://{bucket}.adobeaemcloud.com/adobe/sites/cf/fragments/{fragmentId}' \ -H 'Authorization: Bearer <YOUR_JWT_HERE>' \ -H 'Content-Type: application/json-patch+json' \ -H 'If-Match: string' \ -d '{ "op": "add", "path": " ", "value": "Doe" }' "
according to the Sites API.
However I'm confused regarding the command as I do not know what value do I put in path if my content fragment is at location /content/dam/wknd-shared/en/
where name of the content fragment is custom-author and I want to add "doe" in the property Last Name (lastName in content fragment model) assuming it is blank before. the final output should be as follows.
Please guide me on how to do the same.
Solved! Go to Solution.
Views
Replies
Total Likes
Hi,
Can you try postman or any other tools to test this?
check here the documentation - https://developer.adobe.com/experience-cloud/experience-manager-apis/api/stable/sites/
Hi @vashishth47
Please check the sample command
I think first you need to get the fragmentId using list API
curl -i -X GET \
'https://{bucket}.adobeaemcloud.com/adobe/sites/cf/fragments?cursor=string&limit=1&path=/content/dam/adaptto/presentations/aem-cloud-service-from-a-developer-perspective&references=direct' \
-H 'Authorization: Bearer <YOUR_JWT_HERE>'
This will return the fragmentId
and I assume lastName is the name property for Last Name field, then you can execute the follwoing
curl -i -X PATCH \
'https://{bucket}.adobeaemcloud.com/adobe/sites/cf/fragments/{fragmentId}' \
-H 'Authorization: Bearer <YOUR_JWT_HERE>' \
-H 'Content-Type: application/json-patch+json' \
-H 'If-Match: string' \
-d '{
"op": "add",
"path": "/lastName",
"value": "Doe"
}'
I have used the following command:
curl -i -X PATCH "http://localhost:4502/adobe/sites/cf/fragments/1a9f0dcc-e5f6-462b-9f1b-3d0a631feb0b"
-H "Authorization: Basic YWRtaW46YWRtaW4="
-H "Content-Type: application/json-patch+json"
-H 'If-Match: string'
-d '{"op": "replace" , "path": "/lastName","value": "donny"}'
It is throwing the following error
HTTP/1.1 400 Bad Request
X-Request-Id: 49a56dff-6a29-4aaf-9730-efc9c5681ddc
Content-Type: application/problem+json;charset=utf-8
Content-Length: 187
{"type":"https://api.adobeaemcloud.com/adobe/meta/errors/bad_request",
"title":"Bad Request",
"status":400,
"detail":"Invalid JSON patch.",
"requestId":"49a56dff-6a29-4aaf-9730-efc9c5681ddc"}
can you tell me what am I doing wrong and where I can refer to in future for further clarity.
Hi,
Can you try postman or any other tools to test this?
check here the documentation - https://developer.adobe.com/experience-cloud/experience-manager-apis/api/stable/sites/
Hi @vashishth47 ,
Please refer https://developer.adobe.com/experience-manager/reference-materials/6-5/assets-api-content-fragments/... for CF APIs and https://experienceleaguecommunities.adobe.com/t5/adobe-experience-manager/asset-api-post-request-for... as a reference how to create the JSON.
Regards,
Anupam Patra
@vashishth47 Did you find the suggestions helpful? Please let us know if you require more information. Otherwise, please mark the answer as correct for posterity. If you've discovered a solution yourself, we would appreciate it if you could share it with the community. Thank you!
Views
Replies
Total Likes
To update the "Last Name" field in a content fragment using a PATCH request, follow these steps:
1. Get the fragmentId using a GET request if you don't already have it. Example command:
curl -i -X GET \
'https://{bucket}.adobeaemcloud.com/adobe/sites/cf/fragments?path=/content/dam/your-path&limit=1' \
-H 'Authorization: Bearer <YOUR_JWT_HERE>'
2. Make the PATCH request to update the lastName field: Example:
curl -i -X PATCH \
'https://{bucket}.adobeaemcloud.com/adobe/sites/cf/fragments/{fragmentId}' \
-H 'Authorization: Bearer <YOUR_JWT_HERE>' \
-H 'Content-Type: application/json-patch+json' \
-H 'If-Match: <ETag from GET response>' \
-d '{
"op": "replace",
"path": "/jcr:content/lastName",
"value": "Doe"
}'
Make sure to adjust the path to match the correct path for your content fragment model's lastName field (/jcr:content/lastName is just an example).
If you still face issues: Error "Invalid JSON patch": Check that the path and value are correct and follow the proper structure for your content fragment's model. Test using tools like Postman for debugging.
Hi @vashishth47
Please refer to https://experienceleague.adobe.com/en/docs/experience-manager-cloud-service/content/assets/admin/ass...
and swagger API for request creation: https://developer.adobe.com/experience-manager/reference-materials/6-5/assets-api-content-fragments/...
Views
Likes
Replies
Views
Likes
Replies
Views
Likes
Replies