mmsc2

mmsc2

Problems creating a bucket with google api storage

Hello I am trying to use the google api storage dependencies to create a a bucket in google storage, the problem is that i am not being able to do it because I get this error after ejecution the code

{:error,
 %Tesla.Env{
   __client__: %Tesla.Client{
     adapter: nil,
     fun: nil,
     post: [],
     pre: [
       {Tesla.Middleware.Headers, :call,
        [
          [
            {"authorization",
             "Bearer .."}
          ]
        ]}
     ]
   },
   __module__: GoogleApi.Storage.V1.Connection,
   body: "{\n  \"error\": {\n    \"code\": 400,\n    \"message\": \"Required\",\n    \"errors\": [\n      {\n        \"message\": \"Required\",\n        \"domain\": \"global\",\n        \"reason\": \"required\"\n      }\n    ]\n  }\n}\n",
   headers: [
     {"cache-control", "no-cache, no-store, max-age=0, must-revalidate"},
     {"date", "Tue, 11 Jan 2022 21:36:34 GMT"},
     {"pragma", "no-cache"},
     {"server", "UploadServer"},
     {"vary", "Origin"},
     {"content-length", "191"},
     {"content-type", "application/json; charset=UTF-8"},
     {"expires", "Mon, 01 Jan 1990 00:00:00 GMT"},
     {"x-guploader-uploadid",
      "ADPycdsDF1IdzxGu0SHK7w2m_TtakLOTSAp8SVkr6AeRWIw-2VutyCBr43BVH2PtTgLhQGB8_kz0_gOLwWIT8tJv1QFm84UXPw"},
     {"alt-svc",
      "h3=\":443\"; ma=2592000,h3-29=\":443\"; ma=2592000,h3-Q050=\":443\"; ma=2592000,h3-Q046=\":443\"; ma=2592000,h3-Q043=\":443\"; ma=2592000,quic=\":443\"; ma=2592000; v=\"46,43\""}
   ],
   method: :post,
   opts: [],
   query: [project: "project_id"],
   status: 400,
   url: "https://storage.googleapis.com/storage/v1/b"
 }}


that is not very descriptive of the problem. I am getting the token with Goth and creating a connection with that but still fails. I suspect it is related to the fact that i am not passing a name to the bucket but i can’t confirm it. the documentation is not very helpfull really. the code is the next one

  def create_bucket() do
    {:ok, token} = Goth.Token.for_scope("https://www.googleapis.com/auth/cloud-platform")
    conn = GoogleApi.Storage.V1.Connection.new(token.token)

    project_id = "project_Id"

    {:ok, bucket} = Buckets.storage_buckets_insert(conn, project_id)

end

the project_id is a valid project name extracted from the generated keys of the project in google storage.

First Post!

kartheek

kartheek

Google storage docs say name is a required property in the request body. Buckets: insert  |  Cloud Storage  |  Google Cloud Documentation

Could you try passing name to it ?

You can play around with the api from web page itself using “Try this API” section.

Where Next?

Popular in Questions Top

RisingFromAshes
I’ve read in another post that it may be possible with a router helper - but I couldn’t find an appropriate one, and tbh, I’m still just ...
New
baxterw3b
Hi guys, i’m new in the Elixir world, and i have to say, that i love it! i’m having some problem to understand anonymous functions with ...
New
hariharasudhan94
Lets say I have map like this fetching from my database %{"_id" => #BSON.ObjectId<58eb1a7a9ad169198c3dXXXX>, "email" => ...
New
openscript
Hello! Sorry for this astonishing simple question, but I’m really stuck. I try to set up the intellij-elixir plugin, but I don’t know ho...
New
aalberti333
As the title describes, I’m trying to run Enum.map() over a list of key/value pairs, where the value is a map. My data looks like this: ...
New
Patoshizzle
After calling mix ecto.create I get this error: 17:00:32.162 [error] GenServer #PID<0.412.0> terminating ** (Postgrex.Error) FATAL...
New
senggen
Erlang/OTP 25 [erts-13.2.2] [source] [64-bit] [smp:8:8] [ds:8:8:10] [async-threads:1] 15:22:35.803 [error] gen_event {lager_file_backend...
New

Other popular topics Top

baxterw3b
Hi guys, i’m new in the Elixir world, and i have to say, that i love it! i’m having some problem to understand anonymous functions with ...
New
Qqwy
Original source of discussion: This topic on the Pragmatic Programmers’ Functional Web Development with Elixir, OTP, and Phoenix forum. ...
New
New
stefanchrobot
What’s the safe way to decode a JSON string into a struct? I want to avoid calling String.to_atom. Jason.decode can give me a map with st...
New
sen
Hi All, I set a environment variables in dev.exs , like below code. when i start server, how can i set the ${enable} value? thanks. d...
New
sorentwo
Hello! tl;dr Announcing Oban, an Ecto based job processing library with a focus on reliability and historical observability. After spen...
985 44778 311
New

We're in Beta

About us Mission Statement