We're trying to connect to a new external API for a custom servlet in AEM author but we're getting the following error:
Response: {"error":{"code":"404","message": "Resource not found"}}
We've added the excluded path to the Adobe Granite CRSF Filter and the allowed host to the Apache Sling Referrer Filter. Also we can make post requests to the API using Postman without any issues. Thanks for any advice.
Topics help categorize Community content and increase your ability to discover relevant content.
Views
Replies
Total Likes
Do you see any error in console or error log? Did you try with GET method also, is that working?
can you please provide your Servlet class definition (how you defined) and how you are calling in HTL
above configurations are looking good
CSRF Filter and Referrer Filter
Add the servlet path /bin/mycustompost to the Adobe Granite CSRF Filter's excluded paths.
Add the external API host to the Apache Sling Referrer Filter's allowed hosts.
@Component(service = Servlet.class,
property = {
ServletResolverConstants.SLING_SERVLET_PATHS + "=/bin/mycustompost",
ServletResolverConstants.SLING_SERVLET_METHODS + "=" + HttpConstants.METHOD_POST
})
public class CustomPostServlet extends SlingAllMethodsServlet {
<form id="customPostForm">
<input type="text" name="key" placeholder="Enter value" required>
<button type="submit">Submit</button>
</form
<script>
document.getElementById('customPostForm').addEventListener('submit', function(event) {
event.preventDefault();
var formData = new FormData(this);
fetch('/bin/mycustompost', {
method: 'POST',
body: formData
})
.then(response => response.json())
----
Hi @stiegjo22 ,
Which error you are getting when you try aem servlet endpoint(post) request from postman?
There may be following reason for 404-
Thanks
Now I'm seeing an error related to SSL certificate validation. The PKIX path building failed error indicates that the Java runtime is unable to find a valid certification path to the requested target, which means the SSL certificate of the target server is not trusted by the Java truststore.
11.10.2024 11:52:59.734 *ERROR* Error generating description: PKIX path building failed: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target
javax.net.ssl.SSLHandshakeException: PKIX path building failed: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target
Hi @stiegjo22 ,
Add certificate to the java truststore, you may refer steps mentioned in below thread
Thanks
@stiegjo22 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
Views
Likes
Replies
Views
Likes
Replies