how can i find the jsonadmin endpoint in typo3

Questions around the TYPO3 integration and plugins
Forum rules
Always add your TYPO3, Aimeos and PHP version as well as your environment (Linux/Mac/Win)
Spam and unrelated posts will be removed immediately!
frimi
Posts: 15
Joined: 02 Oct 2020, 15:25

how can i find the jsonadmin endpoint in typo3

Post by frimi » 02 Oct 2020, 15:36

Hi.

I'm writing a typo3 extension (fe plugin) and need access to the jsonadmin REST API to add/update/delete products. It seems to be a good idea to use the admin jsonapi to do that rather then accessing the database directly. I studied the following guide https://aimeos.org/docs/Developers/Admin/JSONAPI but i have no idea how to find the endpoint. I searched all the configs I know, but could't find anything usable. Has anyone ha solution or hint for me?

Kind regards, Michael
Last edited by frimi on 07 Oct 2020, 15:34, edited 1 time in total.

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

Re: how can i find the jsonadmin endpoint in typo3

Post by aimeos » 03 Oct 2020, 07:45

The jsonadm endpoint is only available for backend modules because it requires a backend user to be logged in.

Instead, you should use the Aimeos managers to manipulate the data (and not directly accessing the DB as you've stated correctly). Here you can find the docs how to use them in your own extension:
https://aimeos.org/docs/2020.x/typo3/extend/
Professional support and custom implementation are available at Aimeos.com
If you like Aimeos, Image give us a star

frimi
Posts: 15
Joined: 02 Oct 2020, 15:25

Re: how can i find the jsonadmin endpoint in typo3

Post by frimi » 07 Oct 2020, 15:33

Many thanks für this Hint! I'll make a test how it match my needs. To implement my requirements, a BE module will also work, if this is nescessary to access the JSON admin API. If I take this way, how can I find the API endpoint in the Typo3 Backend?
Last edited by frimi on 08 Oct 2020, 17:34, edited 1 time in total.

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

Re: how can i find the jsonadmin endpoint in typo3

Post by aimeos » 08 Oct 2020, 11:55

The URL is:
http://localhost/typo3/index.php?route= ... n%5D=index

You can use an OPTIONS request to get the available resources and also the token you need to perform any updates.
Professional support and custom implementation are available at Aimeos.com
If you like Aimeos, Image give us a star

frimi
Posts: 15
Joined: 02 Oct 2020, 15:25

Re: how can i find the jsonadmin endpoint in typo3

Post by frimi » 19 Oct 2020, 13:11

I'm trying to use the way described in https://aimeos.org/docs/2020.x/typo3/extend/ but it won't work as espected :(

My Code (in an Controller Action of my plugin):

Code: Select all

	
	 $localConfigArray = array();
 	 $config = \Aimeos\Aimeos\Base::getConfig( $localConfigArray );
 	 $context = \Aimeos\Aimeos\Base::getContext( $config );
 	 $localeMgr = \Aimeos\MShop::create( $context, 'locale' );
 	 $localeItem = $localeMgr->createItem()->setLanguageId( 'de' );
	 $context->setLocale( $localeItem );
         $productMgr = \Aimeos\MShop::create( $context, 'product' );
         $item = $productMgr->getItem('8');
	 // => Result is : 
         // Item with ID "8" in "product.id" not found
         // in .../httpdocs/typo3conf/ext/aimeos/Resources/Libraries/aimeos/aimeos-core/lib/mshoplib/src/MShop/Common/Manager/Base.php line 688
   
Product Id 8 is defind in the database, is enabled and has a category assigned to it and is visible in the frontend/website

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

Re: how can i find the jsonadmin endpoint in typo3

Post by aimeos » 21 Oct 2020, 09:59

Without using the boostrap() method described in the docs, there's no site ID available and you won't get any results:

Code: Select all

$manager = \Aimeos\MShop::create( $context, 'locale' );
$item = $manager->bootstrap( '<sitecode>', '<languageid>', '<currencyid>', true );
$context->setLocale( $item );
Professional support and custom implementation are available at Aimeos.com
If you like Aimeos, Image give us a star

frimi
Posts: 15
Joined: 02 Oct 2020, 15:25

Re: how can i find the jsonadmin endpoint in typo3

Post by frimi » 26 Oct 2020, 13:41

Oh cool, many thanks! Knowing to read is a underestimated skill.... ;)
Now it works and I can get the desired Item. I can now continue to explore the capabilities of the different manager objects to manage the Products and their attributes.
Kind regards, Michael

rvhelp2
Posts: 29
Joined: 29 Oct 2022, 10:10

Re: how can i find the jsonadmin endpoint in typo3

Post by rvhelp2 » 24 Nov 2022, 12:05

How can i get the backend token in javascript?

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

Re: how can i find the jsonadmin endpoint in typo3

Post by aimeos » 25 Nov 2022, 09:41

It's part of the backend URL available in the data-url attribute here:
https://github.com/aimeos/ai-admin-jqad ... e.php#L132
Professional support and custom implementation are available at Aimeos.com
If you like Aimeos, Image give us a star

Post Reply