Page 1 of 1

how can i find the jsonadmin endpoint in typo3

Posted: 02 Oct 2020, 15:36
by frimi
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

Re: how can i find the jsonadmin endpoint in typo3

Posted: 03 Oct 2020, 07:45
by aimeos
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/

Re: how can i find the jsonadmin endpoint in typo3

Posted: 07 Oct 2020, 15:33
by frimi
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?

Re: how can i find the jsonadmin endpoint in typo3

Posted: 08 Oct 2020, 11:55
by aimeos
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.

Re: how can i find the jsonadmin endpoint in typo3

Posted: 19 Oct 2020, 13:11
by frimi
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

Re: how can i find the jsonadmin endpoint in typo3

Posted: 21 Oct 2020, 09:59
by aimeos
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 );

Re: how can i find the jsonadmin endpoint in typo3

Posted: 26 Oct 2020, 13:41
by frimi
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

Re: how can i find the jsonadmin endpoint in typo3

Posted: 24 Nov 2022, 12:05
by rvhelp2
How can i get the backend token in javascript?

Re: how can i find the jsonadmin endpoint in typo3

Posted: 25 Nov 2022, 09:41
by aimeos
It's part of the backend URL available in the data-url attribute here:
https://github.com/aimeos/ai-admin-jqad ... e.php#L132