Empty basket returned
Posted: 20 Dec 2019, 11:00
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