Author Topic: rest api admin missing POST method  (Read 2745 times)

Offline onlyjunior

  • Newbie
  • *
  • Posts: 2
  • Karma: +1/-0
    • View Profile
rest api admin missing POST method
« on: May 20, 2019, 03:18:43 PM »
Hi,
I am working on an extension and I am trying to develop a rest api on the admin side. I was able to do a simple GET and I was able to consume it through POSTMAN, but now I want to do a POST. The problem is that looks like POST method is not allowed.

FYI, on the storefront side, I was able to add some rest api which handle GET, POST, PUT and DELETE (I had to do a simple crud). Is there some reason why it is not allowed by default on the admin side?
In case it is disabled, can someone please tell me (or guide me) on what I have to modify in order to allow it?


Offline onlyjunior

  • Newbie
  • *
  • Posts: 2
  • Karma: +1/-0
    • View Profile
Re: rest api admin missing POST method
« Reply #1 on: May 20, 2019, 07:29:43 PM »
me again, after some tests and after debugging the code, I have found how does it work, I will try to explain here:

Scenario: Suppose we want to provide a route to create a product, so we need to implement a POST method.

In order to consume it, we have to make a
POST to url : localhost/index.php?s=admin&rt=a/myextension/product
and in the body pass the follwing form data:
api_key: YOUR_API_KEY
token: TOKEN_GOT_FROM_LOGIN

If you do a get, you can pass all the parameters as queryparameters as following:

localhost/index.php?s=admin&rt=a/myextension/product&api_key=YOU_API_KEY&token=YOUR_TOKEN

I am not sure if this info will be usefull for someone or it is just me the one who didn't get how it works  ;D

bye

Offline Basara

  • Administrator
  • Hero Member
  • *****
  • Posts: 5774
  • Karma: +274/-2
    • View Profile
Re: rest api admin missing POST method
« Reply #2 on: May 21, 2019, 04:15:12 AM »
Thank you, onlyjunior

 

Powered by SMFPacks Social Login Mod