title: Amazon Polly API
body: <p>I am trying to use Amazon Polly REST API.<br>
  Can someone, please, help me to do this?<br>
  I am using Java and OkHttp3 and tried this:</p>
  
  <pre><code>    String url = "https://polly.us-west-2.amazonaws.com/v1/speech";
      String postBody = "{\"OutputFormat\":\"mp3\",\"Text\":\"Some text to listen\",\"TextType\":\"text\",\"VoiceId\":\"Joanna\"}";
  
      MediaType mediaType = MediaType.parse("application/json; charset=utf-8");
  
      OkHttpClient client = new OkHttpClient.Builder()
              .connectTimeout(30, TimeUnit.SECONDS)
              .readTimeout(30, TimeUnit.SECONDS)
              .build();
  
  
  
      Request request = new Request.Builder()
              .url(url)
              .addHeader("Authorization", "AWS &lt;accessKey&gt;:&lt;secretKey&gt;")
              .post(RequestBody.create(mediaType, postBody))
              .build();
  
      Response response = client.newCall(request).execute();
  </code></pre>
  
  <p>And received "403 forbidden" answer. Then I tried to do this POST request online <a href="https://www.hurl.it/" rel="nofollow noreferrer">on this service</a> and received this:
  <a href="https://i.stack.imgur.com/H7qm4.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/H7qm4.png" alt="enter image description here"></a>
  What am I doing wrong? What should I fix? Thanks!</p>
  
  <p>Amazon docs: <a href="http://docs.aws.amazon.com/AmazonS3/latest/dev/RESTAuthentication.html" rel="nofollow noreferrer">link</a><br>
  And please, dont suggest me to use SDK !</p>
  
  <hr>
  
  <p>I read <a href="http://docs.aws.amazon.com/general/latest/gr/sigv4-signed-request-examples.html" rel="nofollow noreferrer">this</a>, <a href="http://docs.aws.amazon.com/general/latest/gr/signature-v4-test-suite.html" rel="nofollow noreferrer">this</a>, <a href="http://docs.aws.amazon.com/general/latest/gr/sigv4-create-string-to-sign.html" rel="nofollow noreferrer">this</a>, <a href="http://docs.aws.amazon.com/AmazonS3/latest/dev/RESTAuthentication.html" rel="nofollow noreferrer">this</a> and <a href="http://docs.aws.amazon.com/polly/latest/dg/API_SynthesizeSpeech.html#API_SynthesizeSpeech_SeeAlso" rel="nofollow noreferrer">this</a>, and still understand nothing.</p>
  
  <ol>
  <li>I understand that my secretKey is secret and that I need to use encryption.</li>
  <li>I need to do request like as describes <a href="http://docs.aws.amazon.com/general/latest/gr/sigv4-signed-request-examples.html" rel="nofollow noreferrer">here</a>, but I cant understand how to make my own request...
  My parameters: <code>method=POST</code>, <code>host=polly.us-west-2.amazonaws.com</code>, <code>endpoint=https://polly.us-west-2.amazonaws.com/v1/speech</code>, <code>region=us-west-2</code>, <code>content-type=application/json</code>, <code>body of post request={...}</code>, <code>accessKey=...</code>, <code>secretKey=...</code> ..... And how to make this request using OkHttp? Please, help!</li>
  </ol>