title: Amazon S3 AWS starts giving error code 400 for unknown reason
body: <p>I am not sure since when, but on my development machine I get the following error using the AWS SDK with Java:</p>
  
  <pre><code>2015-02-24 18:57:05,834 DEBUG ~ Receiving response: HTTP/1.1 400 Bad Request
  2015-02-24 18:57:05,834 DEBUG ~ &lt;&lt; HTTP/1.1 400 Bad Request
  2015-02-24 18:57:05,834 DEBUG ~ &lt;&lt; Server: nginx
  2015-02-24 18:57:05,834 DEBUG ~ &lt;&lt; Date: Tue, 24 Feb 2015 18:57:05 GMT
  2015-02-24 18:57:05,834 DEBUG ~ &lt;&lt; Content-Type: application/xml
  2015-02-24 18:57:05,834 DEBUG ~ &lt;&lt; Transfer-Encoding: chunked
  2015-02-24 18:57:05,834 DEBUG ~ &lt;&lt; Connection: keep-alive
  2015-02-24 18:57:05,834 DEBUG ~ &lt;&lt; Bucket: "testmedia"
  2015-02-24 18:57:05,834 DEBUG ~ &lt;&lt; Accept-Ranges: bytes
  2015-02-24 18:57:05,834 DEBUG ~ &lt;&lt; Age: 0
  2015-02-24 18:57:05,834 DEBUG ~ &lt;&lt; X-Cache-Hit: No
  2015-02-24 18:57:05,835 DEBUG ~ Connection can be kept alive indefinitely
  2015-02-24 18:57:05,835 DEBUG ~  &lt;&lt; "51[\r][\n]"
  2015-02-24 18:57:05,835 DEBUG ~  &lt;&lt; "&lt;?xml version="1.0" encoding="UTF-8"?&gt;&lt;Error&gt;&lt;Code&gt;InvalidArgument&lt;/Code&gt;&lt;/Error&gt;"
  2015-02-24 18:57:05,835 DEBUG ~  &lt;&lt; "[\r][\n]"
  2015-02-24 18:57:05,835 DEBUG ~  &lt;&lt; "0[\r][\n]"
  2015-02-24 18:57:05,835 DEBUG ~  &lt;&lt; "[\r][\n]"
  2015-02-24 18:57:05,835 DEBUG ~ Connection [id: 8][route: {s}-&gt;https://testmedia.xxx] can be kept alive indefinitely
  2015-02-24 18:57:05,835 DEBUG ~ Connection released: [id: 8][route: {s}-&gt;https://testmedia.xxx][total kept alive: 1; route allocated: 1 of 50; total allocated: 1 of 50]
  2015-02-24 18:57:05,836 DEBUG ~ Received error response: com.amazonaws.services.s3.model.AmazonS3Exception: null (Service: null; Status Code: 400; Error Code: InvalidArgument; Request ID: null), S3 Extended Request ID: null
  </code></pre>
  
  <p>I can upload the file, so the credentials seem ok, but I don't seem to download it. I am using the Play! Framework (1.2.7) running JDK 1.7 and the AWS SDK 1.9.22.</p>
  
  <p>What could be the cause of this?</p>
  
  <p>It is recently that I did switch from JDK 1.6 to 1.7 because of a signing issue on 1.6 with AWS. I don't have it (yet) on my production servers, so it might be OS X related, but don't dare to deploy my code to production until I know for sure it will not break.</p>
  
  <p>(aws-sdk-java/1.9.22 Mac_OS_X/10.10.3 Java_HotSpot(TM)_64-Bit_Server_VM/24.71-b01/1.7.0_71)</p>
  
  <p>[EDIT:]
  My Java code:</p>
  
  <pre><code>AWSCredentials credentials = new BasicAWSCredentials(accessKey, secretKey);
  ClientConfiguration clientConfig = new ClientConfiguration();
  clientConfig.setConnectionTimeout(2500);
  
  AmazonS3 conn = new AmazonS3Client(credentials, clientConfig);
  conn.setEndpoint(hostUrl);    
  S3Object object = conn.getObject(new GetObjectRequest(bucket, fileKey));
  </code></pre>