Here is my servlet code,
@component(service = { Servlet.class })
@SlingServletPaths(value = "/api/assets/eshop")
@ServiceDescription("Get Filtered Assets based on properties and custom response.")
public class AssetFilter extends SlingAllMethodsServlet {
and I have also made the entry in Script Resolver
any help what am I missing here.
Solved! Go to Solution.
Views
Replies
Total Likes
The problem is caused by the fact that you are using endpoint that matches AEM OOTB REST api. In general everything starting with /api/* is part of AEM Core Service and will be handheld by com.adobe.granite.rest.impl.servlet.ApiResourceFilter. You can see all available main endpoints under /api.json
You can observe under /system/console/requests, how /api/* requests are handled:
If you have to use /api prefix, avoid paths like: /api/assets, /api/screens, /api/screens-dcc, /api/content.
Your custom servlet will not be correctly handled by OOTB mechanism, this is why you are getting 406 status.
To solve the problem you can change change your path from /api/assets/eshop to /api/asset/eshop, or use different pattern for the path starting with api except path listed above. However using /bin would be the best idea, as it will not require changes under Servlet/Script resolver.
Hi,
Firstly, the "@component" annotation is incorrect; it should be capitalized as follows: "@Component." I would assume this is a typographical error and not the primary reason for your issue.
In addition, could you please verify whether this servlet is being resolved by accessing http://localhost:4502/system/console/servletresolver? If not, there is an issue with your code deployment
Also, could you compare your code with this example and identify any differences?: https://sourcedcode.com/blog/aem/slingservletpaths-example-code-in-aem
The problem is caused by the fact that you are using endpoint that matches AEM OOTB REST api. In general everything starting with /api/* is part of AEM Core Service and will be handheld by com.adobe.granite.rest.impl.servlet.ApiResourceFilter. You can see all available main endpoints under /api.json
You can observe under /system/console/requests, how /api/* requests are handled:
If you have to use /api prefix, avoid paths like: /api/assets, /api/screens, /api/screens-dcc, /api/content.
Your custom servlet will not be correctly handled by OOTB mechanism, this is why you are getting 406 status.
To solve the problem you can change change your path from /api/assets/eshop to /api/asset/eshop, or use different pattern for the path starting with api except path listed above. However using /bin would be the best idea, as it will not require changes under Servlet/Script resolver.
Thanks. It was really helpful. And I was wondering why every other url works, but this.
Views
Likes
Replies
Views
Likes
Replies