403 Forbidden Error While Getting Indexes From AWS Elastic Search Using AWS SDK

I am using AWS SDK to connect to elastic search. I am following

Other question in this topic were more like permission issues or issue while writing to elasticsearch. For me writing is working fine, only reading is giving me the error

The POST method works all fine and it is adding the indexes. I am making a GET request for search in the same manner

  public void getIndexedRecords(String index,String type,String id,String documentJSON){

        try {
            String endpoint = host +"/" +index+"/_search" ;
            // Builds the request. We need an AWS service, URI, HTTP method, and request
            // body (in this case, JSON).

            Request<?> request = new DefaultRequest<Void>(service);
            request.setEndpoint(new URI(endpoint));
            request.setContent(new ByteArrayInputStream(documentJSON.getBytes()));

            // Retrieves our credentials from the computer. For more information on where
            // this class looks for credentials, see

            String accessKey = CommonUtils.getCommonProperty("accessKey", "");
            String secretKey = CommonUtils.getCommonProperty("secretKey", "");;
            AWSCredentials creds = new BasicAWSCredentials(accessKey, secretKey);

            // Signs the request using our region, service, and credentials. AWS4Signer
            // modifies the original request rather than returning a new request.

            AWS4Signer signer = new AWS4Signer();
            signer.sign(request, creds);
            request.addHeader("Content-Type", "application/json");

            // Creates and configures the HTTP client, creates the error and response
            // handlers, and finally executes the request.

            ClientConfiguration config = new ClientConfiguration();
            AmazonHttpClient client = new AmazonHttpClient(config);
            ExecutionContext context = new ExecutionContext(true);
            ESAWSErrorHandler errorHandler = new ESAWSErrorHandler();
            ESAWSResponseHandler<Void> responseHandler = new ESAWSResponseHandler<Void>();
        } catch (Exception e) {


But it gives me a 403 forbidden error. When I do Curl XGET with my endpoint url I am getting the result. What am I doing wrong here?

com.amazonaws.AmazonServiceException: (Service: null; Status Code: 403; Error Code: Forbidden; Request ID: null) at com.amazonaws.http.AmazonHttpClient$RequestExecutor.handleErrorResponse( at com.amazonaws.http.AmazonHttpClient$RequestExecutor.executeOneRequest( at com.amazonaws.http.AmazonHttpClient$RequestExecutor.executeHelper( at com.amazonaws.http.AmazonHttpClient$RequestExecutor.doExecute( at com.amazonaws.http.AmazonHttpClient$RequestExecutor.executeWithTimer( at com.amazonaws.http.AmazonHttpClient$RequestExecutor.execute( at com.amazonaws.http.AmazonHttpClient$RequestExecutor.access$500( at com.amazonaws.http.AmazonHttpClient$RequestExecutionBuilderImpl.execute(