title: Copy object in Google Cloud Storage
body: <p>I'm using the Java client for Google Cloud Platform to copy an object from inside a bucket to a different place in the same bucket.</p>
  
  <p>To do that I followed the instructions <a href="https://cloud.google.com/storage/docs/json_api/v1/objects/copy" rel="nofollow">here</a>, but I'm getting a <code>GoogleJsonResponseException 404 Bad Request</code>:</p>
  
  <pre><code>class com.google.api.client.googleapis.json.GoogleJsonResponseException: 400 Bad Request
  {
    "code" : 400,
    "errors" : [ {
      "domain" : "global",
      "message" : "Required",
      "reason" : "required"
    } ],
    "message" : "Required"
  }
  </code></pre>
  
  <p>This is my code:</p>
  
  <pre><code>GoogleCredential credential = GoogleCredential.fromStream(new FileInputStream("key.json"))
                      .createScoped(Collections.singleton(StorageScopes.CLOUD_PLATFORM));
  
              storageClient = new Storage.Builder(httpTransport, jsonFactory, credential).build();
  
   StorageObject newObject = new StorageObject();
              newObject.setName(newName);
  
              Storage.Objects.Copy request = storageClient.objects().copy(bucketName, objectName, bucketName, newName, newObject);
              request.setDestinationPredefinedAcl("publicread");
  
              request.execute();
  </code></pre>
  
  <p>So far this is the only operation that fails, upload, download, getLength and a few others work just fine.</p>
  
  <p><strong>Update:</strong></p>
  
  <p>I manage to make it work removing this line:</p>
  
  <pre><code>request.setDestinationPredefinedAcl("publicread");
  </code></pre>
  
  <p>Anyway I would like to know what's wrong since in the future I would like to be able to chose if the new object is public or private.</p>