Empty basket returned
Forum rules
Always add your Laravel, Aimeos and PHP version as well as your environment (Linux/Mac/Win)
Spam and unrelated posts will be removed immediately!
Always add your Laravel, Aimeos and PHP version as well as your environment (Linux/Mac/Win)
Spam and unrelated posts will be removed immediately!
-
- Posts: 44
- Joined: 05 Oct 2019, 06:42
Empty basket returned
Hi,
I am using "aimeos/aimeos-laravel": "~2019.10.1", "aimeoscom/ai-sites": "^2019.10" and have installed Laravel passport. Now For the Aimeos JSON API to work now we need to pass Authorization: Bearer token and Accept: application/json in the headers for each request and the token is attached to a customer id.
Now I added a product in the basket using the following URL-:
The product gets added fine and it returns
Now when I try to fetch the basket I am using the ebdaa-ecommerce-beta.test/default/jsonapi/basket url.
I pass the same Authorization token in this request and it returns empty.
I am not using session driver as db. Infact I am using file.
How can I get the basket where I added the product after integrating the Laravel passport? Do I need to pass some other session token in the request? Please assist.
Thank you
I am using "aimeos/aimeos-laravel": "~2019.10.1", "aimeoscom/ai-sites": "^2019.10" and have installed Laravel passport. Now For the Aimeos JSON API to work now we need to pass Authorization: Bearer token and Accept: application/json in the headers for each request and the token is attached to a customer id.
Now I added a product in the basket using the following URL-:
Code: Select all
http://ebdaa-ecommerce-beta.test/default/jsonapi/basket?id=default&related=product
{"data":[{"attributes":{"product.id": 15,"quantity": 1}}]}
Code: Select all
{
"meta": {
"total": 1,
"prefix": null,
"content-baseurl": "http://ebdaa-ecommerce-beta.test/",
"csrf": {
"name": "_token",
"value": ""
}
},
"links": {
"self": {
"href": "http://ebdaa-ecommerce-beta.test/default/jsonapi/basket?id=default&related=product",
"allow": [
"DELETE",
"GET",
"PATCH",
"POST"
]
},
"basket/product": {
"href": "http://ebdaa-ecommerce-beta.test/default/jsonapi/basket?id=default&related=product",
"allow": [
"POST"
]
},
"basket/service": {
"href": "http://ebdaa-ecommerce-beta.test/default/jsonapi/basket?id=default&related=service",
"allow": [
"POST"
]
},
"basket/address": {
"href": "http://ebdaa-ecommerce-beta.test/default/jsonapi/basket?id=default&related=address",
"allow": [
"POST"
]
},
"basket/coupon": {
"href": "http://ebdaa-ecommerce-beta.test/default/jsonapi/basket?id=default&related=coupon",
"allow": [
"POST"
]
}
},
"data": {
"id": "default",
"type": "basket",
"links": {
"self": {
"href": "http://ebdaa-ecommerce-beta.test/default/jsonapi/basket?id=default",
"allow": [
"DELETE",
"GET",
"PATCH",
"POST"
]
}
},
"attributes": {
"order.base.id": null,
"order.base.sitecode": "",
"order.base.customerid": "8",
"order.base.languageid": "en",
"order.base.currencyid": "EUR",
"order.base.price": "100.00",
"order.base.costs": "5.00",
"order.base.rebate": "0.00",
"order.base.taxvalue": "17.5000",
"order.base.taxflag": true,
"order.base.customerref": "",
"order.base.comment": ""
},
"relationships": {
"basket/product": {
"data": [
{
"type": "basket/product",
"id": 0
}
]
},
"basket/service": {
"data": [
{
"type": "basket/service",
"id": "delivery"
}
]
},
"basket/address": {
"data": [
{
"type": "basket/address",
"id": "payment"
}
]
}
}
},
"included": [
{
"id": 0,
"type": "basket/product",
"attributes": {
"order.base.product.id": null,
"order.base.product.price": "100.00",
"order.base.product.costs": "5.00",
"order.base.product.rebate": "0.00",
"order.base.product.taxrate": "20.00",
"order.base.product.taxrates": {
"": "20.00"
},
"order.base.product.type": "default",
"order.base.product.stocktype": "default",
"order.base.product.suppliercode": "",
"order.base.product.prodcode": "demo-article",
"order.base.product.productid": "15",
"order.base.product.quantity": 1,
"order.base.product.name": "Demo article",
"order.base.product.description": "",
"order.base.product.mediaurl": "https://demo.aimeos.org/media/1.jpg",
"order.base.product.timeframe": "",
"order.base.product.position": null,
"order.base.product.status": -1
},
"links": {
"self": {
"href": "http://ebdaa-ecommerce-beta.test/default/jsonapi/basket?id=default&related=product&relatedid=0",
"allow": [
"DELETE",
"PATCH"
]
}
}
},
{
"id": "delivery",
"type": "basket/service",
"attributes": {
"order.base.service.id": null,
"order.base.service.price": "0.00",
"order.base.service.costs": "0.00",
"order.base.service.rebate": "0.00",
"order.base.service.taxrate": "0.00",
"order.base.service.taxrates": {
"": "0.00"
},
"order.base.service.type": "delivery",
"order.base.service.code": "demo-pickup",
"order.base.service.name": "Click & Collect",
"order.base.service.position": null,
"order.base.service.mediaurl": ""
},
"links": {
"self": {
"href": "http://ebdaa-ecommerce-beta.test/default/jsonapi/basket?id=default&related=service&relatedid=delivery",
"allow": [
"DELETE"
]
}
}
},
{
"id": "payment",
"type": "basket/address",
"attributes": {
"order.base.address.id": null,
"order.base.address.salutation": "",
"order.base.address.company": "",
"order.base.address.vatid": "",
"order.base.address.title": "",
"order.base.address.firstname": "",
"order.base.address.lastname": "",
"order.base.address.address1": "",
"order.base.address.address2": "",
"order.base.address.address3": "",
"order.base.address.postal": "",
"order.base.address.city": "",
"order.base.address.state": "",
"order.base.address.countryid": "",
"order.base.address.languageid": "",
"order.base.address.telephone": "",
"order.base.address.telefax": "",
"order.base.address.email": "john@admin.com",
"order.base.address.website": "",
"order.base.address.longitude": null,
"order.base.address.latitude": null,
"order.base.address.type": "payment",
"order.base.address.position": null,
"order.base.address.addressid": "8"
},
"links": {
"self": {
"href": "http://ebdaa-ecommerce-beta.test/default/jsonapi/basket?id=default&related=address&relatedid=payment",
"allow": [
"DELETE"
]
}
}
}
]
}
I pass the same Authorization token in this request and it returns empty.
Code: Select all
{
"meta": {
"total": 1,
"prefix": null,
"content-baseurl": "http://ebdaa-ecommerce-beta.test/",
"csrf": {
"name": "_token",
"value": ""
}
},
"links": {
"self": {
"href": "http://ebdaa-ecommerce-beta.test/default/jsonapi/basket",
"allow": [
"DELETE",
"GET",
"PATCH",
"POST"
]
},
"basket/product": {
"href": "http://ebdaa-ecommerce-beta.test/default/jsonapi/basket?id=default&related=product",
"allow": [
"POST"
]
},
"basket/service": {
"href": "http://ebdaa-ecommerce-beta.test/default/jsonapi/basket?id=default&related=service",
"allow": [
"POST"
]
},
"basket/address": {
"href": "http://ebdaa-ecommerce-beta.test/default/jsonapi/basket?id=default&related=address",
"allow": [
"POST"
]
},
"basket/coupon": {
"href": "http://ebdaa-ecommerce-beta.test/default/jsonapi/basket?id=default&related=coupon",
"allow": [
"POST"
]
}
},
"data": {
"id": "default",
"type": "basket",
"links": {
"self": {
"href": "http://ebdaa-ecommerce-beta.test/default/jsonapi/basket?id=default",
"allow": [
"DELETE",
"GET",
"PATCH",
"POST"
]
}
},
"attributes": {
"order.base.id": null,
"order.base.sitecode": "",
"order.base.customerid": "8",
"order.base.languageid": "en",
"order.base.currencyid": "EUR",
"order.base.price": "0.00",
"order.base.costs": "0.00",
"order.base.rebate": "0.00",
"order.base.taxvalue": "0.0000",
"order.base.taxflag": true,
"order.base.customerref": "",
"order.base.comment": ""
},
"relationships": []
},
"included": []
}
How can I get the basket where I added the product after integrating the Laravel passport? Do I need to pass some other session token in the request? Please assist.
Thank you
Re: Empty basket returned
Yes, I think you still need to pass the Laravel session token because the OAuth token is only used for authentication but not for session management in Laravel.
Professional support and custom implementation are available at Aimeos.com
If you like Aimeos, give us a star
If you like Aimeos, give us a star
-
- Posts: 44
- Joined: 05 Oct 2019, 06:42
Re: Empty basket returned
Please tell us, which Laravel Session cookie key and value I need to pass? Do I need to create a new session, cookie somewhere and then pass that key and value in each API request? Please guide us. We are stuck and not able to progress from here . We need to get the basket product we added but not able to figure this out as it is returning empty basket each time. An example would be appreciated.
Thank you
Thank you
Re: Empty basket returned
Professional support and custom implementation are available at Aimeos.com
If you like Aimeos, give us a star
If you like Aimeos, give us a star
-
- Posts: 1
- Joined: 03 Apr 2020, 04:27
Re: Empty basket returned
Thanks for the clarificationadityabanerjee wrote: ↑22 Dec 2019, 18:32 Please tell us, which Laravel Session cookie key and value I need to pass? Do I need to create a new session, cookie somewhere and then pass that key and value in each API request? Please guide us. We are stuck and not able to progress from here . We need to get the basket product we added but not able to figure this out as it is returning empty basket each time. An example would be appreciated.
Thank you