instructure / pandarus

A Ruby library for the Canvas API (and code generator for other languages, eventually)
34 stars 24 forks source link

create_new_sub_account performs a GET instead of POST #19

Closed johnnaegle closed 7 years ago

johnnaegle commented 8 years ago

The generated implementation of create_new_sub_account is

RemoteCollection.new(connection, Account, path, query_params)

It should be

response = mixed_request(:post, path, query_params, form_params, headers)
Account.new(response)

When this request is run:

client.create_new_sub_account(1, {name: "Programs"})

It generates this request in Canvas:

Started GET "/api/v1/accounts/1/sub_accounts" 
Processing by AccountsController#sub_accounts as JSON
  Parameters: {"account_id"=>"1"}

I made the change to use mixed_request and I was able to successfully create a sub account:

Started POST "/api/v1/accounts/1/sub_accounts" for 127.0.0.1 at 2016-09-26 16:02:38 -0500
Processing by SubAccountsController#create as JSON
  Parameters: {"account"=>{"name"=>{"name"=>"Programs"}}, "account_id"=>"1"}
johnnaegle commented 8 years ago

I eyeballed the rest of the create methods in the generated API and they all look correct. I tried to track down why it generated a RemoteCollection instead of Account.new but I could not find the magic.

simonista commented 7 years ago

Fixed in 820155f977c6dbf933e9bff558439e51915459f5