Question

I have followed setting up Broadleaf to make it running by following its documentation (http://docs.broadleafcommerce.org/current/REST-Tutorials.html). The setup website works fine. Howver, when I tested the Adding an item to the shopping cart REST api, I found that it caused me an error. Here is my input:

url: localhost:8080/api/cart/2003/100?skuId=100&customerId=1101 request method: POST

found error:[ERROR] 02:15:57 DefaultErrorHandler - An error occurred during the workflow org.broadleafcommerce.core.order.service.exception.RequiredAttributeNotProvidedException: Unable to add to product (100) cart. Required attribute was not provided: COLOR

My setup environment is: - Broadleaf commerce 2.2 - MySql database whose data comes from Braodleaf DemoSite.

Was it helpful?

Solution

You are seeing this because you have some required product options configured for that particular product but did not pass those required attributes into your request. Try your request again with a request like this:

localhost:8080/api/cart/2003/100?customerId=1101&COLOR=BLUE

This assumes that you have a 'BLUE' product option value corresponding to the COLOR product option.

That being said, it looks like there might be a bug here because if you explicitly passed in a skuId in the request like you did, it should use that as priority. The current code assumes that you are selecting a Sku either by product option value lookup (this takes priority) and THEN checks the passed in Sku ID. When the system attempts to look up a Sku based on the product option values that were passed in (in this case, there were none) it sees that you did not pass in a required product option (COLOR in this case) and throws the exception.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top