Closed exemplari closed 3 years ago
Can you please post the output that has been returned by the API?
{
"meta": {
"total": 1,
"prefix": null,
"content-baseurl": "/aimeos",
"csrf": {
"name": "_token",
"value": "i1oWnlC5qATlB2V9X0J0kgjOftMNniOhIr2j0ZK8"
}
},
"links": {
"self": {
"href": "http://domain.com/jsonapi/basket?id=default&related=product",
"allow": ["DELETE", "GET", "PATCH", "POST"]
},
"basket/product": {
"href": "http://domain.com/jsonapi/basket?id=default&related=product",
"allow": ["POST"]
},
"basket/service": {
"href": "http://domain.com/jsonapi/basket?id=default&related=service",
"allow": ["POST"]
},
"basket/address": {
"href": "http://domain.com/jsonapi/basket?id=default&related=address",
"allow": ["POST"]
},
"basket/coupon": {
"href": "http://domain.com/jsonapi/basket?id=default&related=coupon",
"allow": ["POST"]
}
},
Thanks. What is the requested URL that returns that response?
Post a product to http://domain.com/jsonapi/basket?id=default&related=product
The self
link is correct because you've sent a POST request to /jsonapi/basket?id=default&related=product
I understand how that could make sense, but ....
But isn't this returning a Basket
Good point. We've changed that in dev-master
and 2021.07.x-dev
. Can you give it a try?
I just tried the -dev branch and it works as expected. The basket is dependably referenced with links.self. The documentation needs updating to match https://aimeos.org/docs/latest/frontend/jsonapi/basket-products/ . Also I see a data.links.self - perhaps this is the place where the request link should display.
"name": "aimeos/ai-client-jsonapi", "version": "2021.07.x-dev", "reference": "b2ec6fc312ccfd2da0791bca8f41db8c70ee0483"
Thanks, fixed now in 2021.x docs.
My issue arose with trying to send a DELETE request to clear the basket.
First add some products with a POST to the product url . /jsonapi/basket?id=default&related=product { product data }
Store the response to my local basket model including the 'links' to modify the basket later.
Send a DELETE to the provided basket links.self.href , error bad JSON in response.
The issue I found was the basket self link provided by the first request was incorrect. Here is the link being provided by the Add Product basket response in links.self.href -> /jsonapi/basket?id=default&related=product
The correct link in side links.self.href should be /jsonapi/basket?id=default
"name": "aimeos/ai-client-jsonapi", "version": "2021.07.1",