1

I am integrating Amazon Product Api in my rails app. The only thing remaining now is fetching related items list when I am performing the item_lookup operation.

When I add RelatedItems in ResponseGroup like this:

    response = request.item_lookup(
    query: {
        'ItemId' => params[:id],
        'ResponseGroup' => "ItemAttributes,Images,Reviews,RelatedItems"
    }
    )

I get this error:

"Errors"=>{"Error"=>{"Code"=>"AWS.MissingParameterValueCombination", "Message"=>"Your request is missing a required parameter combination.  When ResponseGroup equals RelatedItems, RelationshipType must be present."}}}

It seems that I need to add RelationshipType in my query.

The issue is I have my categories being saved in the backend. The search_index and keyword is passed to the item_search operation where I fetch the ASIN which I pass as param to item_lookup operation. The issue is how can I add RelationshipType over here and also that it has to dynamic as per the product being displayed.

Thanks in advance.

techdreams
  • 5,371
  • 7
  • 42
  • 63

1 Answers1

1

Could you simply add all existing RelationshipType values to your ItemLookup request. The RelationshiptType set is limited to 15 valid values, so you could include all of them into your request as follows:

response = request.item_lookup(
query: {
    'ItemId' => params[:id],
    'ResponseGroup' => "ItemAttributes,Images,Reviews,RelatedItems"
    ...
    'RelationshipType' => "Tracks,DigitalMusicArranger,DigitalMusicComposer,DigitalMusicConductor,DigitalMusicEnsemble,DigitalMusicLyricist,DigitalMusicPerformer,DigitalMusicPrimaryArtist,DigitalMusicProducer,DigitalMusicRemixer,DigitalMusicSongWriter,Episode,Season"
}
)
CyberMJ
  • 865
  • 2
  • 12
  • 25