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.”

on
var currency = _requestModelAccessor.RequestModel.Cart.Currency;
or
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.

litium_logo_signature_small_77e9390f-80dc-4260-8c77-753ba9d8224f.PNG

Signatur-ny-bla_62b7c5a6-09fc-4294-bb83-3c624e047ad7.png

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