I'm guessing variant can't seem to find product (specific exception in
variant.rb) :

def check_price
if price.nil? && Spree::Config[:require_master_price]
raise 'No master variant found to infer price' unless (product && product.master)
raise 'Must supply price for variant or master.price for product.' if self == product.master
self.price = product.master.price
end
if currency.nil?
self.currency = Spree::Config[:currency]
end
end


I do send product_id ( twice even in the following)

curl -i -X POST -H "X-Spree-Token: my-personal-token" -d
"variant[price]=99.99&variant[product_id]=2"
http://localhost:3001/api/products/2/variants.json

I'll try overriding api/variants_controller#create as the next step, i
guess.


Tom

Op woensdag 27 februari 2013 00:17:49 UTC+1 schreef Tom Mestdagh het
volgende:
I'm not able to create a variant through the rest api, i get a
ResourceInvalid error.
What fields need to be present to create a product variant? It's no
problem when not using rest, and i don't seem to find anything in the docs
or in source.

Anyone who has done this, creating a variant through rest api?


Tom
--
You received this message because you are subscribed to the Google Groups "Spree" group.
To unsubscribe from this group and stop receiving emails from it, send an email to spree-user+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

Search Discussions

Related Discussions

Discussion Navigation
viewthread | post
Discussion Overview
groupspree-user @
categoriesrubyonrails
postedFeb 27, '13 at 4:27p
activeFeb 27, '13 at 4:27p
posts1
users1
websitespreecommerce.com
irc#RubyOnRails

1 user in discussion

Tom Mestdagh: 1 post

People

Translate

site design / logo © 2022 Grokbase