Hi,
I am trying to make a connection to kendra and used the following lines of code.
String accessKey = <xxxxxxxxxxxxxxxxxxx>;
String secretKey = <xxxxxxxxxxxxxxx>;
String indexId = <xxxxxxxxxxxxxx>;
AwsCredentials awsCredentials = AwsBasicCredentials.create(accessKey, secretKey);
//S/dkHttpClient httpClient = ApacheHttpClient.builder().build();
KendraClient kendraClient = KendraClient.builder()
.region(Region.US_EAST_1)
.credentialsProvider(() -> awsCredentials)
.build();
// Set up the query request with attribute filter
QueryRequest queryRequest = QueryRequest.builder()
.queryText(searchWord)
.indexId(indexId)
.build();
QueryResponse queryResult = kendraClient.query(queryRequest);
I am getting the following error :
Thanks in advance!
Solved! Go to Solution.
Views
Replies
Total Likes
I would recommend you to first get the request working as expected on the Postman API Platform, to test out the API, client secrets and credentials, and then finally use httpClient to make the request.
While making the https requests, I recommend you to use the org.apache.http.osgi.services.HttpClientBuilderFactory, so you can write unit tests for this as expected.
Example to writeHttpClientBuilderFactory requests and unit tests, JUnit 5: Mocking the HttpClient in Java - Sourced Code
Issue resolved after creating new access key.
Thanks
Views
Likes
Replies