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

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

srinivasu
How to handle excepions in elixir? Suppose i have A, B, C ,D, E modules. and each module has get() function. A.get() method will call th...
New
albydarned
Hello all! I am typing this post from my new MacBook Pro with the M1 chip. I’m loving it so far, and will probably use it as my daily dr...
New
pgiesin
This should be a simple problem but I just can’t seem to figure it out. I have a standalone Elixir app that won’t find the database. Dep...
New
New
quazar
How to set Jason to encode all fields in ecto schema, I don’t care about security and implementing only is taking long list of attributes...
New
fireproofsocks
I’m working on defining a simple Ecto schema for a table (in PostGres), but I don’t see where I can define a column as NOT NULL. Conside...
New
aadeshere1
I have a another noob question about loop. Since elixir is immutable, while loop is not directly possible. total = 10 while total != 0 ...
New
stefanluptak
Hello everybody, usually, I use a 29" ultra-wide monitor for VSCode which can easily accomodate explorer (files panel) + file with code ...
New
WestKeys
Currently suffering from paralysis by [HTTP client] analysis. This is rather unusual in Elixirland as there tends to be consensus on the ...
New
Mooodi
Given a string, how can I get access to its character by index? Enum.at("my_string", 2) doesn't work. Or rather, not char, but a substr...
New

Other popular topics Top

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
srinivasu
How to handle excepions in elixir? Suppose i have A, B, C ,D, E modules. and each module has get() function. A.get() method will call th...
New
jerry
Good day to you all. I have been struggling to get a query involving like and ilike to work. Can anyone assist me on this, please? pro...
New
_russellb
I want to try my hand at web scraping. What tools/libraries do I need to use. I’m hoping to turn this into something professional so don’...
New
SoCreat
i’m a new one to elixir which editor can i use vs code? or atom? Thanks! :smiley:
New
nsuchy
Hi. I’ve noticed that Windows Powershell has it’s own IEX command and you cannot access Elixir’s IEX due to the conflict. This isn’t a cr...
New
fayddelight
I tried installing elixir 1.11.2 erlang 23.3.4 via asdf in my zsh shell. Enabled the versions locally and globally. When I list them ...
New
johnnyicon
Hi all, I've just started learning Elixir and Phoenix Framework, so please pardon my n00bness at this stage. I'm trying to use Postg...
New
electic
Hi, I am new to Elixir. I am trying to use the DateTime component to insert a date into MySQL however the there seems to be no way to fo...
New
siddhant3030
Hi, I have to write a raw query for one of my project. But till now I have used ecto queries and don’t have much experience writing raw ...
New

We're in Beta

About us Mission Statement