Welcome Guest, Not a member yet? Register   Sign In
Consume API externally
#1

(This post was last modified: 09-28-2021, 08:11 AM by RRIOS.)

I need to use a query using CI4, via an app. I already have the CRUD, but I need it to send the PK through an app and return json.

1- I created a controller that I tested via browser ( htttp://localhost/mycontroller/54265 ) and it's ok.
2- I tested (and obviously) it didn't work to access this controller directly in the browser (http://192.168.0.13/ci4/public/mycontroller)

How through an app (where I usually post www mysite com/myapi/parameter ) will I be able to directly access my controller to return the json?

I did try in Routes :

$routes->add('vercli/(:num)', 'Vercli:: show/$1');

and this

2-$routes->post('vercli/(:num)', 'VerCli:: show/$1);
But it doesn't run the show method. Executes the VerCli index method.

3- I changed the search(code block) from the show($id=null) method to the index($id=null) method and receiving parameter. But the parameter is not recognized ( null ) and change in Routes - $routes->post('vercli/(:num)','VerCli::index/$1');

4- I removed the line above (from the Routes file) result:
nothing changed (it wasn't working).
Reply


Messages In This Thread
Consume API externally - by RRIOS - 09-28-2021, 05:51 AM
RE: Consume API externally - by includebeer - 10-04-2021, 04:23 PM
RE: Consume API externally - by RRIOS - 10-05-2021, 01:34 PM
RE: Consume API externally - by includebeer - 10-05-2021, 02:54 PM
RE: Consume API externally - by RRIOS - 10-05-2021, 04:28 PM
RE: Consume API externally - by includebeer - 10-05-2021, 05:18 PM



Theme © iAndrew 2016 - Forum software by © MyBB