I have a CF model linked to a CF folder under DAM. When I create a CF manually using the Touch UI, it works perfectly, and I can create and retrieve the CF successfully. However, when I try to create a CF using the Asset API, I receive a 500 error response. Upon checking the logs, I found the following error.
POST /api/assets/content-management/country-mapping/test.json HTTP/1.1] com.adobe.granite.rest.impl.servlet.PostRequest Exception during request processing.
java.lang.NullPointerException: null
at com.adobe.granite.rest.impl.servlet.JSONUtil.walk(JSONUtil.java:56) [com.adobe.granite.rest.api:1.1.16.CQ650-B0007]
at com.adobe.granite.rest.impl.servlet.JSONUtil.walk(JSONUtil.java:64) [com.adobe.granite.rest.api:1.1.16.CQ650-B0007]
at com.adobe.granite.rest.impl.servlet.JSONUtil.toJcrMap(JSONUtil.java:51) [com.adobe.granite.rest.api:1.1.16.CQ650-B0007]
at com.adobe.granite.rest.impl.servlet.ModifyingRequest.createOrModifyResource(ModifyingRequest.java:102) [com.adobe.granite.rest.api:1.1.16.CQ650-B0007]
at com.adobe.granite.rest.impl.servlet.PostRequest.doHandle(PostRequest.java:56) [com.adobe.granite.rest.api:1.1.16.CQ650-B0007]
at com.adobe.granite.rest.impl.servlet.AbstractRequest.handle(AbstractRequest.java:75) [com.adobe.granite.rest.api:1.1.16.CQ650-B0007]
at com.adobe.granite.rest.impl.servlet.DefaultServlet.handleRequest(DefaultServlet.java:101) [com.adobe.granite.rest.api:1.1.16.CQ650-B0007]
at com.adobe.granite.rest.impl.servlet.DefaultServlet.doPost(DefaultServlet.java:159) [com.adobe.granite.rest.api:1.1.16.CQ650-B0007]
at org.apache.sling.api.servlets.SlingAllMethodsServlet.mayService(SlingAllMethodsServlet.java:146) [org.apache.sling.api:2.22.0.B002]
at com.adobe.granite.rest.impl.servlet.DefaultServlet.mayService(DefaultServlet.java:275) [com.adobe.granite.rest.api:1.1.16.CQ650-B0007]
at org.apache.sling.api.servlets.SlingSafeMethodsServlet.service(SlingSafeMethodsServlet.java:342) [org.apache.sling.api:2.22.0.B002]
at org.apache.sling.api.servlets.SlingSafeMethodsServlet.service(SlingSafeMethodsServlet.java:374) [org.apache.sling.api:2.22.0.B002]
at org.apache.sling.engine.impl.request.RequestData.service(RequestData.java:579) [org.apache.sling.engine:2.7.10.B0006]
at org.apache.sling.engine.impl.filter.SlingComponentFilterChain.render(SlingComponentFilterChain.java:45) [org.apache.sling.engine:2.7.10.B0006]
at org.apache.sling.engine.impl.filter.AbstractSlingFilterChain.doFilter(AbstractSlingFilterChain.java:82) [org.apache.sling.engine:2.7.10.B0006]
at com.adobe.granite.rest.assets.impl.AssetContentDispositionFilter.doFilter(AssetContentDispositionFilter.java:96) [com.adobe.granite.rest.assets:1.0.58.CQ650-B0002]
Solved! Go to Solution.
Topics help categorize Community content and increase your ability to discover relevant content.
Views
Replies
Total Likes
Hi @Nishanth_KR ,
I was able to create a CF using below JSON
{
"properties": {
"contentFragment": true,
"name": "test",
"cq:model": "/conf/global/settings/dam/cfm/models/product-data",
"title": "test",
"description": "test",
"elementsOrder": [
"someData1",
"someData2"
],
"elements": {
"someData1": "dfdf",
"someData2": "abc"
}
}
}
But when I added some rubbish data on "elements" which are not part of the CF Model, it gives me a 500 Response.
Maybe there's a mismatch between the data or data type with the CF Model & the CF you are trying to create.
Ps- I tried it on AEM as a cloud.
Regards,
Anupam Patra
Hi @Nishanth_KR ,
Can you confirm you are using these APIs correctly to create the CF ?
Regards,
Anupam Patra
@anupampatYes, I am using the API format specified in the Swagger documentation. Here is the JSON data for the request and body that I am trying to post to create the CF.
Request URL :
http://localhost:4502/api/assets/content-management/country-mapping/test.json
Request body:
{
"properties": {
"contentFragment": true,
"name": "test",
"cq:model": "/conf/my-content-fragments/settings/dam/cfm/models/country-number-mapping",
"title": "test",
"description": "test",
"createdBy": "admin",
"created": 1737115187690,
"modifiedBy": "admin",
"modified": 1737115187690,
"elementsOrder": [
"country",
"phoneNumber"
],
"elements": {
"country": {
"variationsOrder": [],
":type": "string",
"variations": {},
"dataType": "string",
"title": "country",
"multiValue": false,
"value": "India"
},
"phoneNumber": {
"variationsOrder": [],
":type": "string",
"variations": {},
"dataType": "string",
"title": "Phone Number",
"multiValue": false,
"value": "1111111111"
}
}
}
}
Views
Replies
Total Likes
Hi @Nishanth_KR ,
I was able to create a CF using below JSON
{
"properties": {
"contentFragment": true,
"name": "test",
"cq:model": "/conf/global/settings/dam/cfm/models/product-data",
"title": "test",
"description": "test",
"elementsOrder": [
"someData1",
"someData2"
],
"elements": {
"someData1": "dfdf",
"someData2": "abc"
}
}
}
But when I added some rubbish data on "elements" which are not part of the CF Model, it gives me a 500 Response.
Maybe there's a mismatch between the data or data type with the CF Model & the CF you are trying to create.
Ps- I tried it on AEM as a cloud.
Regards,
Anupam Patra
I am using AEM 6.5.20. Thanks for your help! I tried removing some data inside the elements JSON, but the POST request still didn’t work. However, I managed to solve the issue by following these steps:
I received a successful response after following the steps mentioned above.
"properties": {
"path": "/api/assets/content-management/country-mapping/test",
"parentLocation": "/api/assets/content-management/country-mapping.json",
"referer": "",
"changes": [
{
"argument": "/api/assets/content-management/country-mapping/test",
"type": "modified"
}
],
"location": "/api/assets/content-management/country-mapping/test.json",
"status.message": "OK",
"title": "Content modified /api/assets/content-management/country-mapping/test",
"status.code": 200
}
Views
Replies
Total Likes
Views
Replies
Total Likes
@PRATHYUSHA_VP Thanks for your response. I found the solution based on @anupampat ’s reply and implemented a workaround. It’s working fine now. I am able to create a CFs via Asset API