Expand my Community achievements bar.

SOLVED

Error while calling kendra API : The request signature we calculated does not match the signature you provided

Avatar

Level 2

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 : 

The request signature we calculated does not match the signature you provided. Check your AWS Secret Access Key and signing method. Consult the service documentation for details. (Service: Kendra, Status Code: 400, Request ID: 06ce1fc5-e040-4939-9a85-3e9b245f7a2e)

 

Thanks in advance!

1 Accepted Solution

Avatar

Correct answer by
Level 2

Issue resolved after creating new access key. 

 

Thanks 

View solution in original post

2 Replies

Avatar

Community Advisor

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

Avatar

Correct answer by
Level 2

Issue resolved after creating new access key. 

 

Thanks