title: Getting the region of an Amazon bucket using webservice
body: <p>I would like to get the location of my bucket by calling Amazons web service.
  I'm using the following url : -</p>
  
  <pre><code>https://mybucketname.amazonaws.com/location?
  X-Amz-Expires=86400&amp;
  X-Amz-Algorithm=AWS4-HMAC-SHA256&amp;
  X-Amz-Credential=&lt;Access Key&gt;%2F20170524%2Fus-east-1%2Fs3%2Faws4_request&amp;
  X-Amz-Date=20170524T162340Z&amp;X-Amz-SignedHeaders=host&amp;
  X-Amz-Signature=f800dce1258a3d43d19929a37c98f3dedf5e5164e807ccf70ef396be5a1e7cf0
  </code></pre>
  
  <p>Unfortunately it comes back with an error: -</p>
  
  <blockquote>
    <p>Error parsing the X-Amz-Credential parameter; the region 'us-east-1' is wrong; expecting 'eu-west-2'</p>
  </blockquote>
  
  <p>That's probably because I have used <code>us-east-1</code> in the <code>X-Amz-Credential</code> part of the request. It is a requirement that region be added to <code>X-Amz-Credential</code>.
  The trouble is I don't know what region I should be using because this is the very thing I'm trying to find out.</p>
  
  <p>Is there a better way to get the region?</p>