Insert basket with error code 400

Here is the code segment:

Bucket newBucket = storage.buckets().insert("MyProject", new Bucket().setName("MyBucket").setLocation("US").setStorageClass("DURABLE_REDUCED_AVAILABILITY")).execute();
 } catch (GoogleJsonResponseException e) {
      System.out.println("Exception in tryCreateBucket: "+e);
      throw e;
 }

It throws: An exception in tryCreateBucket:

com.google.api.client.googleapis.json.GoogleJsonResponseException: 400 Bad Request
{
  "code" : 400,
  "errors" : [ {
    "domain" : "global",
    "message" : "Invalid Value",
    "reason" : "invalid"
  } ],
  "message" : "Invalid Value"
}

Any thoughts on how to fix this problem?

Thank you / VK

+4
source share
2 answers

bucket names must be lowercase. There are also a number of other restrictions - see https://developers.google.com/storage/docs/bucketnaming#requirements

+3
source

Your project name is incorrect, you need the form foo-barbar-12345 that Google assigned, and not the simple name you gave it (CloudStorage)

+2
source

Source: https://habr.com/ru/post/1536614/


All Articles