Hi @ashishg1547773
You can also use SlingRequestProcessor Library. It requires AEM system user to make a request similar to HTTP request. The system user must have access to path where you are making a request.
You can take a look at the sample code:
String assetUrl = assetPath + ".1.json";
HttpServletRequest request = requestResponseFactory.createRequest("GET", assetUrl);
request.setAttribute(WCMMode.REQUEST_ATTRIBUTE_NAME, WCMMode.DISABLED);
ByteArrayOutputStream out = new ByteArrayOutputStream();
HttpServletResponse response = requestResponseFactory.createResponse(out);
try {
requestProcessor.processRequest(request, response, resourceResolver);
String jsonString = out.toString(HQConstants.UTF_8_ENCODING);
} catch (ServletException | IOException e) {
}
Here, you need resourceResolver which must be of system user with right access rights. The above makes same request as HTTP request and as your requirment, does not need credentials.
Hope it helps!
Thanks!
Nupur