Search code examples
best-buy-api

Cannot query with slashes for modelNumber


Apple headphones for example have a model number of MD827LL/A

When I query http://api.remix.bestbuy.com/v1/products(modelNumber=MD827LL%2FA&manufacturer=Apple&active=true&onlineAvailability=true)?show=sku,name,regularPrice,salePrice,onSale,productId,linkShareAffiliateUrl,url,customerReviewAverage,freeShipping,freeShippingEligible,onlineAvailability,inStoreAvailability,shippingCost,marketplace,manufacturer,modelNumber&pageSize=1&apiKey={}&format=json

OR

http://api.remix.bestbuy.com/v1/products(modelNumber=MD827LL/A&manufacturer=Apple&active=true&onlineAvailability=true)?show=sku,name,regularPrice,salePrice,onSale,productId,linkShareAffiliateUrl,url,customerReviewAverage,freeShipping,freeShippingEligible,onlineAvailability,inStoreAvailability,shippingCost,marketplace,manufacturer,modelNumber&pageSize=1&apiKey={}&format=json

Response: "status": "400 Bad Request", "message": "Couldn't understand"

How can I resolve?


Solution

  • There are two pieces that we need to fix with this query to make it return the data you are asking for. The first you correctly identified with the Model number having slashes returning 400s. This is solved by putting quotes around your model number to deal with the slash interfering with html encoding.

    The other piece, once you get around the slashes in the model number, is that the manufacturer=Apple won't work as written because Apple shows up as Apple® in our API (and everywhere else it can). This is solved by including a wildcard at the end of Apple. So changing "manufacturer=Apple" to "manufacturer=Apple*" works.

    In the end, you should have a url that looks like this:

    http://api.remix.bestbuy.com/v1/products(modelNumber=%22MD827LL/A%22&manufacturer=%22Apple*%22&active=true&onlineAvailability=true)?show=sku,name,regularPrice,salePrice,onSale,productId,linkShareAffiliateUrl,url,customerReviewAverage,freeShipping,freeShippingEligible,onlineAvailability,inStoreAvailability,shippingCost,marketplace,manufacturer,modelNumber&pageSize=1&format=json&apiKey={}

    I hope this helps.