solidus icon indicating copy to clipboard operation
solidus copied to clipboard

Admin api users cannot create an order with line items

Open rileyanderson opened this issue 6 years ago • 2 comments

Api users that have admin role cannot create an order with line items though the api. When a user has an admin role it assumes that the intent is to import an order. https://github.com/solidusio/solidus/blob/master/api/app/controllers/spree/api/orders_controller.rb#L36-L38

Solidus Version: Master

To Reproduce

  • Assign user admin role.
  • Create order with line items though api.

Current behavior Throws an error - NoMethodError: undefined method 'each_key' for [{"variant_id"=>xx, "quantity"=>xx}] as importer expects a hash of hashes instead of an array of hashes.

https://github.com/solidusio/solidus/blob/master/core/lib/spree/core/importer/order.rb#L99-L112

Expected behavior Should not call importer in this instance. Ideally importer would be a separate endpoint.

rileyanderson avatar Nov 07 '19 17:11 rileyanderson

@rileyanderson I agree with you, we should have a single behavior for this endpoint, or at least make it work with the same data both ways.

kennyadsl avatar Nov 28 '19 15:11 kennyadsl

@rileyanderson Hey there, I'm taking a look at this but it looks like the accepted parameters are the same for both those endpoints. We have also a spec covering your scenario.

Can you please describe the context of the error better?

kennyadsl avatar Dec 02 '19 10:12 kennyadsl