Reputation: 418
I'm using the shopify app gem (https://github.com/Shopify/shopify_app) to create an embedded app in my client's shopify site. I'm trying to iterate through one of our db's tables and create a new product in shopify for each row.
class ProductController < ApplicationController
around_filter :shopify_session
layout 'embedded_app'
def new
@parts = Part.all
@parts.each do |part|
@product = ShopifyAPI::Product.new
@product.title = part.style_name
@product.sku = part.sku
@product.upc = part.upc
@product.weight = part.weight
@product.product_type = "Part"
@product.vendor = part.vendor
@product.tags = "part"
@product.save
end
end
end
I am working locally and when I hit product new action I get this error: "Failed. Response code = 403. Response message = Forbidden."
Upvotes: 0
Views: 443
Reputation: 36
Best solution would be to remove the Appplication Controller and add like this ProductController < ShopifyApp::AuthenticatedController By this you will directly get access to the sessions
Upvotes: 0
Reputation: 418
I was getting a 403 because I had to visit /login first to create a new sessions by entering my shop's domain.
Upvotes: 0
Reputation: 8202
So, "Missing site URI" means you did not activate a session with the Shopify API server before asking it to persist data. You need to get a token from the API first, using the domain name and the token from the shop into which you're loading the products.
I need more information in order to help you more, if needed.
Upvotes: 2