Admin api users cannot create an order with line items
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 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.
@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?