Search code examples
herokuheroku-api

How to programatically create Hobby of type `Dyno` from Heroku API (Preferrably with Ruby)?


The following method returns a 422 HTTP status code when I attempt to create a Dyno with the heroku app api:

  client = PlatformAPI.connect_oauth(API_KEY)
  dyno_interface = PlatformAPI::Dyno.new(client)
  begin
    dyno_interface.create('my-cool-app', {"command" => " bin/rails server -p 
  $PORT -e $RAILS_ENV", "size" => "hobby", "type"=> "run"})
  rescue => e
   resp = e.response
  end

It fails with the message: Requested type Hobby is not available. Please use Free.

If it matters, I've tried on different versions of the Ruby client, (version 2.0.0). Also, my app does not currently have a Procfile but I was unsure if this would matter.

TLDR: How can I automatically create Dynos of type Hobby via the Heroku API (preferably in Ruby).


Solution

  • Never did figure out how to change the dyno type from Ruby so instead we ended up calling bash/Heroku CLI from ruby.

    Still interested if anyone knows how to do this from Ruby.