I am testing the api call from console:
ShopifyAPI::Product.all
then got the error ShopifyAPI::ApiVersion::ApiVersionNotSetError (You must set ShopifyAPI::Base.api_version before making a request.)
I have tried to set api_version by set api_version before calling the api:
ShopifyAPI::Base.api_version = '2019-04'
But still get the same error.
When I check the API version with ShopifyAPI::Base.api_version I get the below info from console. I don't know why all flags are FALSE....
=> #<ShopifyAPI::ApiVersion:0x00007fb09f1cdfc0 @handle="2019-04", @display_name="2019-04", @supported=false, @latest_supported=false, @verified=false>
My gemfile:
ruby '2.6.1'
gem 'rails', '~> 5.2.2'
gem 'pg', '>= 0.18', '< 2.0'
gem 'puma', '~> 3.11'
gem 'sass-rails', '~> 5.0'
gem 'uglifier', '>= 1.3.0'
gem 'webpacker'
gem 'rabl'
gem 'email_validator'
gem 'slim-rails'
gem 'bcrypt', '~> 3.1.7'
gem 'mini_magick', '~> 4.8'
gem 'pundit'
gem 'rails-env-credentials'
gem 'aws-sdk', '~> 3'
gem 'shopify_app'
gem 'bootsnap', '>= 1.1.0', require: false
group :development do
gem 'web-console', '>= 3.3.0'
gem 'listen', '>= 3.0.5', '< 3.2'
gem 'spring'
gem 'spring-watcher-listen', '~> 2.0.0'
end
gemfile.lock
shopify_api (8.0.0)
activeresource (>= 4.1.0, < 6.0.0)
graphql-client
rack
shopify_app (11.3.2)
browser_sniffer (~> 1.1.3)
dotenv-rails (~> 2.7.5)
omniauth-shopify-oauth2 (~> 2.2.0)
rails (> 5.2.1)
shopify_api (~> 8.0)
Any idea how to fix this error?
I have to init the session first:
session = ShopifyAPI::Session.new(domain: "MY_SHOP.myshopify.com", token: Shop.first.shopify_token, api_version: "2019-10")
ShopifyAPI::Base.activate_session(session)
Most helpful comment
I have to init the session first:
session = ShopifyAPI::Session.new(domain: "MY_SHOP.myshopify.com", token: Shop.first.shopify_token, api_version: "2019-10")ShopifyAPI::Base.activate_session(session)