Aimeos Create an new extension and Api in it.

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
TEJASPARMAR
Posts: 15
Joined: 20 Mar 2024, 11:53

Aimeos Create an new extension and Api in it.

Post by TEJASPARMAR » 30 May 2024, 12:25

I want to create a new Api inside the extension I have created and installed on my store.
I can call Api but cannot call Post Api and pass data to the Api.

Any suggestions or examples for the are appreciated.
PHP version : 8.1.28
AIMEOS version : 2022.10.9
Environment : Linux
Last edited by TEJASPARMAR on 31 May 2024, 09:23, edited 1 time in total.

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

Re: Aimeos Create an new extension and Api in it.

Post by aimeos » 31 May 2024, 09:08

Can you provide some more information?
Which Aimeos version do you use?
What API do you want to extend?
Please post examples of your GET and POST requests and responses.
Professional support and custom implementation are available at Aimeos.com
If you like Aimeos, Image give us a star

User avatar
TEJASPARMAR
Posts: 15
Joined: 20 Mar 2024, 11:53

Re: Aimeos Create an new extension and Api in it.

Post by TEJASPARMAR » 01 Jun 2024, 09:14

Get Api : http://local.aimeos/jsonapi/punchoutsso
Response: message printed in get function of standard.php file

Post: http://local.aimeos/jsonapi/punchoutsso
Response: Page Expired.

I want to call the post method and pass JSON data to the function on the post.
AIMEOS version : 2022.10.9

User avatar
TEJASPARMAR
Posts: 15
Joined: 20 Mar 2024, 11:53

Re: Aimeos Create an new extension and Api in it.

Post by TEJASPARMAR » 01 Jun 2024, 14:18

TEJASPARMAR wrote: 01 Jun 2024, 09:14 Get Api : http://local.aimeos/jsonapi/punchoutsso
Response: message printed in get function of standard.php file

Post: http://local.aimeos/jsonapi/punchoutsso
Response: Page Expired.

I want to call the post method and pass JSON data to the function on the post.
AIMEOS version : 2022.10.9
AIMEOS version : 2022.10.9

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

Re: Aimeos Create an new extension and Api in it.

Post by aimeos » 02 Jun 2024, 06:48

For POST/PATCH/DELETE requests, you have to include the "_token" parameter with the Laravel X-CSRF-TOKEN value.
Professional support and custom implementation are available at Aimeos.com
If you like Aimeos, Image give us a star

User avatar
TEJASPARMAR
Posts: 15
Joined: 20 Mar 2024, 11:53

Re: Aimeos Create an new extension and Api in it.

Post by TEJASPARMAR » 03 Jun 2024, 11:00

OK, Thanks for the reply.
Can you guide me on how to get a token in an Aimeos?

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

Re: Aimeos Create an new extension and Api in it.

Post by aimeos » 04 Jun 2024, 07:12

First, make sure you send the session cookie with each request: https://aimeos.org/docs/latest/frontend ... i/baskets/
Then, in every response of the JSON:API, there's a "meta" section with a "csrf" sub-section containing the token name and value: https://aimeos.org/docs/latest/frontend ... the-basket
Professional support and custom implementation are available at Aimeos.com
If you like Aimeos, Image give us a star

User avatar
TEJASPARMAR
Posts: 15
Joined: 20 Mar 2024, 11:53

Re: Aimeos Create an new extension and Api in it.

Post by TEJASPARMAR » 05 Jun 2024, 12:39

Thanks, it is working now.
The post method is also working with CSRF TOKEN.

now, I want to add a redirection code in "public function get"

public function get( ServerRequestInterface $request, ResponseInterface $response ) : \Psr\Http\Message\ResponseInterface
{
//code**********


return redirect()->intended('/');

}
If I am using this, It is now allowing me to redirect.
Can you please suggest, how can we redirect from there?

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

Re: Aimeos Create an new extension and Api in it.

Post by aimeos » 06 Jun 2024, 07:34

You shouldn't send a redirect in a JSON:API response because it violates the JSON:API specs. Instead, return the redirect URL in the meta section of the response or as "next" link so the client can care about.
Professional support and custom implementation are available at Aimeos.com
If you like Aimeos, Image give us a star

User avatar
TEJASPARMAR
Posts: 15
Joined: 20 Mar 2024, 11:53

Re: Aimeos Create an new extension and Api in it.

Post by TEJASPARMAR » 12 Jun 2024, 11:35

Can we create a page in an extension?
if yes.
How can we create a page and define its route in an extension only?

Post Reply