Jsonapi fetch basket always empty

How to configure and adapt Aimeos based shops as developer
Forum rules
Always add your Aimeos and PHP version as well as your environment (Linux/Mac/Win)
Spam and unrelated posts will be removed immediately!
MilaWeb
Posts: 11
Joined: 13 Oct 2022, 16:42

Jsonapi fetch basket always empty

Post by MilaWeb » 06 Jan 2023, 17:08

Jsonapi fetch basket always empty
Aimeos version 2022.10.3 Laravel version 9.31.0, PHP version 8.0.23, Ubuntu 20.04.5 LTS

In JSON API basket save give always empty basket response.
Here example form postman.
First is add product to basket - it works.
After that fetch - and it's empty
At .env - SESSION_DRIVER=file
Attachments
basket_created.jpg
basket_created.jpg (113.65 KiB) Viewed 2298 times
always_empty.jpg
always_empty.jpg (107.92 KiB) Viewed 2298 times

User avatar
aimeos
Administrator
Posts: 7866
Joined: 01 Jan 1970, 00:00

Re: Jsonapi fetch basket always empty

Post by aimeos » 08 Jan 2023, 09:35

Do you pass the Laravel session ID (e.g. "aimeos_session") to the API too?
Otherwise, the server doesn't know that your requests belong together.
Professional support and custom implementation are available at Aimeos.com
If you like Aimeos, Image give us a star

MilaWeb
Posts: 11
Joined: 13 Oct 2022, 16:42

Re: Jsonapi fetch basket always empty

Post by MilaWeb » 09 Jan 2023, 09:42

Looks like no. I used csrf token. But as I show at fetch basket sreen - order.base.customerid is present and it's real user login id that I logged in. In this case don't know why basket empty. Could be please some details about ID (aimeos_session) value. Where I can check that it turn on (and see value) and where I should put it at Api basket fetch call

User avatar
aimeos
Administrator
Posts: 7866
Joined: 01 Jan 1970, 00:00

Re: Jsonapi fetch basket always empty

Post by aimeos » 11 Jan 2023, 09:06

The ID of a registered user is irrelevant, all basket data is stored in the Laravel session so guest checkouts are also possible. The Laravel session token is a cookie sent by Laravel to the client over HTTP. You can see it in the network section of the browser console.
Professional support and custom implementation are available at Aimeos.com
If you like Aimeos, Image give us a star

MilaWeb
Posts: 11
Joined: 13 Oct 2022, 16:42

Re: Jsonapi fetch basket always empty

Post by MilaWeb » 11 Jan 2023, 14:10

I checked also Web version: add product to Basket - and there is present laravel_session for logged in user, but basket always empty too. Nothing add there. If I go to checkout page after add product nothing change. Stock for product is present (37).
Maybe there some value at config or anything else to check?
Attachments
stock_level.jpg
stock_level.jpg (59.37 KiB) Viewed 2216 times
1_empty_basket.jpg
1_empty_basket.jpg (144.8 KiB) Viewed 2216 times

User avatar
aimeos
Administrator
Posts: 7866
Joined: 01 Jan 1970, 00:00

Re: Jsonapi fetch basket always empty

Post by aimeos » 12 Jan 2023, 09:51

There seems to be something else wrong. Some things to check:
- Is the laravel_session cookie always the same?
- Is the basket stored in the mshop_order_basket table?
- Does it also occur if you disable rate limiting (which seems to be activated by you according to your screenshot)?
Professional support and custom implementation are available at Aimeos.com
If you like Aimeos, Image give us a star

User avatar
aimeos
Administrator
Posts: 7866
Joined: 01 Jan 1970, 00:00

Re: Jsonapi fetch basket always empty

Post by aimeos » 13 Jan 2023, 11:36

If you install aimeos/ai-client-html:2022.10.x-dev, there's a fix for displaying error messages in overlays. They had been skipped before. Maybe that helps debugging:

Code: Select all

composer aimeos/ai-client-html:2022.10.x-dev
Professional support and custom implementation are available at Aimeos.com
If you like Aimeos, Image give us a star

MilaWeb
Posts: 11
Joined: 13 Oct 2022, 16:42

Re: Jsonapi fetch basket always empty

Post by MilaWeb » 31 Jan 2023, 16:00

Thank you for all explanation.Everything is worked - added \Illuminate\Session\Middleware\StartSession at Api routes at Kernel.

Post Reply