How to use AWS Translate "TranslateText" API via POSTMAN

1.8k views Asked by At

I am building a POC using AWS Translate and one of the requirement is to use REST API.

I have constructed the below url :

enter image description here

but when I hit the url using POSTMAN I get the below error :

{
    "__type": "UnknownOperationException"
}
1

There are 1 answers

2
aksyuma On BEST ANSWER

I have managed to find a fix to my issue. The issue was that, I was expecting the "x-amz-target" header to have a friendly name e.g "translate" but from this link, the "x-amz-target" header needs to be "AWSShineFrontendService_20170701.TranslateText"

Solution:

  1. In postman, I created a new POST request.

  2. I then changed the URL specific to an AWS Translate region from:

    https://translate.us-east-1.amazonaws.com/TranslateText
    

to :

    https://translate.us-east-1.amazonaws.com/
  1. Under "Headers" I added the following headers:

    Content-Type: application/x-amz-json-1.1
    X-Amz-Target: AWSShineFrontendService_20170701.TranslateText

  2. Under "Body", I selected "raw", and added the following sample body:

    {
      "SourceLanguageCode": "en",
      "TargetLanguageCode": "fr",
      "Text": "Creating a test terminology in AWS Translate"
    }
    

After testing again I got it working, as you can see in the screenshot below :

AWS_Translate_POSTMAN