add new JSON API resouce

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!
User avatar
мужыковмужыков
Posts: 10
Joined: 08 Sep 2023, 08:52

add new JSON API resouce

Post by мужыковмужыков » 09 Sep 2023, 14:56

Hi,
How can I add a new custom JSON API resource and use it?

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

Re: add new JSON API resouce

Post by aimeos » 10 Sep 2023, 08:32

If you have created a manager for a new data domain that contains only one table (and no lists or property table), then you can query the new resource directly over the JSON API. Just configure the new resource in the ./config/client.php file of your extension:

Code: Select all

'jsonapi' => [
	'resources => [
		'mydomain' => 'mydomain'
	]
]
See also: https://github.com/aimeos/ai-client-jso ... client.php
Professional support and custom implementation are available at Aimeos.com
If you like Aimeos, Image give us a star

User avatar
мужыковмужыков
Posts: 10
Joined: 08 Sep 2023, 08:52

Re: add new JSON API resouce

Post by мужыковмужыков » 10 Sep 2023, 16:33

aimeos wrote: 10 Sep 2023, 08:32 If you have created a manager for a new data domain that contains only one table (and no lists or property table), then you can query the new resource directly over the JSON API. Just configure the new resource in the ./config/client.php file of your extension:

Code: Select all

'jsonapi' => [
	'resources => [
		'mydomain' => 'mydomain'
	]
]
See also: https://github.com/aimeos/ai-client-jso ... client.php
I've added my own resource, but it works only with GET method, for other method I receive 419 Error (Page Expired). How I can fix that? I tried post method into class, but it still not working

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

Re: add new JSON API resouce

Post by aimeos » 10 Sep 2023, 19:08

Send the CSRF token in the URL of the POST request like for the basket:
https://aimeos.org/docs/latest/frontend ... i/baskets/
Professional support and custom implementation are available at Aimeos.com
If you like Aimeos, Image give us a star

Post Reply