Error while calling kendra API : The request signature we calculated does not match the signature you provided | Community
Skip to main content
May 17, 2024
Solved

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

  • May 17, 2024
  • 2 replies
  • 925 views

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!

This post is no longer active and is closed to new replies. Need help? Start a new post to ask your question.
Best answer by SushmaNa

Issue resolved after creating new access key. 

 

Thanks 

2 replies

BrianKasingli
Community Advisor and Adobe Champion
Community Advisor and Adobe Champion
May 18, 2024

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

SushmaNaAuthorAccepted solution
May 27, 2024

Issue resolved after creating new access key. 

 

Thanks