ericcj/amz_sp_api

Calling get_feed(FEED_ID) results in undefined method `build_from_hash' for Feed:Class

Opened this issue · 4 comments

After successfully submitting a feed, when we call get_feed(FEED_ID), it always throws this error:

7: from /var/www/ncube_ecomm/releases/20221019163120/app/proxies/amzn_sp_api/feed_proxy.rb:19:inget_feed'
6: from /var/www/ncube_ecomm/shared/bundle/ruby/2.5.0/gems/amz_sp_api-1.0.0/lib/feeds-api-model/api/feeds_api.rb:190:in get_feed' 5: from /var/www/ncube_ecomm/shared/bundle/ruby/2.5.0/gems/amz_sp_api-1.0.0/lib/feeds-api-model/api/feeds_api.rb:226:in get_feed_with_http_info'
4: from /var/www/ncube_ecomm/shared/bundle/ruby/2.5.0/gems/amz_sp_api-1.0.0/lib/sp_api_client.rb:18:in call_api' 3: from /var/www/ncube_ecomm/shared/bundle/ruby/2.5.0/gems/amz_sp_api-1.0.0/lib/api_client.rb:72:in call_api'
2: from /var/www/ncube_ecomm/shared/bundle/ruby/2.5.0/gems/amz_sp_api-1.0.0/lib/api_client.rb:200:in deserialize' 1: from /var/www/ncube_ecomm/shared/bundle/ruby/2.5.0/gems/amz_sp_api-1.0.0/lib/api_client.rb:239:in convert_to_type'
NoMethodError (undefined method build_from_hash' for Feed:Class)

Can you please fix it?

we use this method successfully. do you have another class named Feed in your codebase and what is its namespace? the one it intends to use has a build_from_hash method https://github.com/ericcj/amz_sp_api/blob/main/lib/feeds-api-model/models/feed.rb#L222 but i wouldn't be surprised if there was a bug in this line that somehow is picking up yours https://github.com/ericcj/amz_sp_api/blob/main/lib/api_client.rb#L239

I am getting same error, using ruby-3.3.2 ETHON: performed EASY effective_url=https://sellingpartnerapi-na.amazon.com/reports/2021-06-30/reports/105390019918 response_code=200 return_code=ok total_time=0.137147
app/models/amazon_seller_orderv2.rb:75:in load': undefined method build_from_hash' for class Report (NoMethodError)
from (irb):3:in `

'

You most likely have a report model, add this method to your model.

Class Report 

…

def self.build_from_hash(data)
   AmzSpApi::ReportsApiModel::Report.build_from_hash(data)
  end

…

end

Thank you @mendywoly. You are correct. It works perfectly now.