heroku / platform-api

Ruby HTTP client for the Heroku API
MIT License
214 stars 85 forks source link

Issue with domain#create #86

Open slant opened 6 years ago

slant commented 6 years ago

I'm hoping I'm just doing something wrong here. When calling heroku.domain.create(), I'm getting a 400 error.

To start, here's what works.

irb(main):003:0> heroku.domain.list('app12345@heroku.com')
=> [{"acm_status"=>nil, ...}]

irb(main):004:0> heroku.domain.delete('app12345@heroku.com', '*.example.com')
=> {"acm_status"=>nil, ...}
# I was able to confirm that this does delete the domain

And here's what doesn't.

irb(main):005:0> heroku.domain.create('UUID_HERE', '*.example.com')
Excon::Error::NotFound: Expected([200, 201, 202, 204, 206, 304]) <=> Actual(404 Not Found)

irb(main):006:0> heroku.domain.create('my-app-name', '*.example.com')
Excon::Error::BadRequest: Expected([200, 201, 202, 204, 206, 304]) <=> Actual(400 Bad Request)

irb(main):007:0> heroku.domain.create('app12345@heroku.com', '*.example.com')
Excon::Error::BadRequest: Expected([200, 201, 202, 204, 206, 304]) <=> Actual(400 Bad Request)

Our API docs suggest that either the UUID or app name should suffice (even the heroku_id works in the delete example above!), which makes me wonder why using the UUID returns a 404 while the app name example returns a 400.

Am I just doing something dumb? It seems pretty straightforward.

Update: in a humbling turn of events, the alternate error I was receiving above for the UUID method was indeed valid; I somehow had the wrong UUID for the app. correcting this yields the same 400 BadRequest error the other two commands were returning.

Using EXCON_DEBUG returns the following (assuming the important bits, omitting others - let me know if you need something else):

  :body                => "\"*.example.com\""
  :host                => "api.heroku.com"
  :hostname            => "api.heroku.com"
  :method              => :post
  :path                => "/apps/UUID_HERE/domains"
mikehale commented 6 years ago

The second parameter requires an object. Try something like: heroku.domain.create(app, {hostname: '*.example.com'}).

You can also check the error messages for clues by setting EXCON_DEBUG=1 in the environment.