Cart acces cart from api? "Cant store OrderCarrier into users session.'"

Today I picked up an old piece of code that used to work, it’s an API that calls the ProductItemViewModelBuilder, but calling gets this error:

“System.NotSupportedException - Cant store OrderCarrier into users session.”

var currency = _requestModelAccessor.RequestModel.Cart.Currency;
var currency = Cart.Currency;

am fairly sure this worked a couple of versions ago, any input?

Litium version: 7.4.2

In general the WebAPI controller suppose to be session less, the cart in Litium is stored in session. This is handled in the accelerators Global.asax file and turning on session state behavior for all request starting with /api/. Make a breakpoint in that method to see that the request if turning on the session.

1 Like

Ah thats why, i have switched from /api/ to /json/ so i just need to add /json?

Edit: Worked like a charm, but if _requestModelAccessor.RequestModel.Cart.Currency will write to the session, should we use something else to get the Currency?

Yes, just add the json as a check in the global.asax also.



This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.