Page 1 of 1
Create new resource items Postman
Posted: 12 Jan 2021, 10:27
by CairMK
Hi all trying to add a new product using postman, my postman request is:
image 1 auth with laravel passport token
second image json body
what I'm doing wrong pls help
Re: Create new resource items Postman
Posted: 13 Jan 2021, 09:17
by aimeos
The JSON REST API is only for the frontend and doesn't allow managing products. You need to use the JsonAdm API for managing products:
https://aimeos.org/docs/latest/admin/jsonadm/
Re: Create new resource items Postman
Posted: 13 Jan 2021, 09:49
by CairMK
I have changed the URL in postman but still not working no error no info according to the doc how I understand,
the URL is
http://localhost:8000/jsonadm/default/product method is post and in the body we need
{
"data": {
"type": "product",
"attributes": {
"product.code": "test",
"product.label": "Test product",
"product.status": "0"
}
}
}
the token need to be pass in the URL as well or just using postman in the header pls give me an example in postman
Re: Create new resource items Postman
Posted: 13 Jan 2021, 10:40
by aimeos
Don't know Postman but CURL should be similar. Here's the excerpt from the docs:
Code: Select all
curl -b cookies.txt -c cookies.txt \
-X POST 'http://localhost:8000/jsonadm/default/product?_token=...' \
-H 'Content-Type: application/json' \
-d '{"data": {
"type": "product",
"attributes": {
"product.code": "test",
"product.label": "Test product",
"product.status": "0"
}
}}'
Make sure you are logged in with an admin account and you pass the Laravel session cookie along with the request.