2013-06-26 27 views
1

我一直在尝试使用shopify_api gem上传资产。我确信我有适当的OAuth2范围(write_themes),并且读取甚至销毁它们都没有问题。问题是在尝试创建或更新资产时出现404错误。写入Shopify资产时发生404错误

这里的宝石创建请求:

PUT: /admin/themes/3650318/assets.json [{"Content-Type"=>"application/json", "User-Agent"=>"ShopifyAPI/3.0.3 ActiveResource/4.0.0.beta1 Ruby/2.0.0", "X-Shopify-Access-Token"=>"ommitted"}] ({"key":"templates/index.liquid","attachment":"base64 attachment omitted"}) 

仅供参考,这里是(当然包裹在ShopifyAPI::Session,)我用来做请求的代码:

ShopifyAPI::Asset.create(key: 'snippets/test.liquid', attachment: some_base64_data, theme_id: 3650318) 

或者:

asset = ShopifyAPI::Asset.new(key: 'snippets/test.liquid', attachment: baset64_data, theme_id: 3650318) 
asset.save 

任何想法?

回答

0

这对我的作品......

要上传到发布的主题(无主题ID给出)

a = ShopifyAPI::Asset.new 
a.key = "assets/google.png" 
a.src = "https://www.google.co.uk/images/srpr/logo11w.png" 
a.save 

ShopifyAPI::Asset.create(key: 'assets/google.png', src: "https://www.google.co.uk/images/srpr/logo11w.png") 

要上传到特定的主题

a = ShopifyAPI::Asset.new 
a.key = "assets/google.png" 
a.src = "https://www.google.co.uk/images/srpr/logo11w.png" 
a.prefix_options[:theme_id] = "6731537" 
a.save 

ShopifyAPI::Asset.create(key: 'assets/google.png', src: "https://www.google.co.uk/images/srpr/logo11w.png", theme_id: 6731537)