Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Web Development
  3. API : resource NOT FOUND

API : resource NOT FOUND

Scheduled Pinned Locked Moved Web Development
phpjsonjavascriptdatabaselearning
3 Posts 2 Posters 3 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • D Offline
    D Offline
    darlina
    wrote on last edited by
    #1

    I'm trying to make an API of my application using CodeIgniter 4 (PHP, Javascript), but when I clicked Send(in postman) with URL: http://localhost:8080/lampiran, it always showing '404 Not Found'(The requested resource /lampiran was not found). This is my controller :

    class Lampiran extends ResourceController
    {
    protected $model = 'App\Models\lampiranModel';
    protected $format = 'json';

    public function index()
    {
        $data = \[
            'message' => 'success',
            'data\_lampiran' => $this->model->findAll()
        \];
        return $this->respond($data, 200);
    }
    

    .....

    and this is my route

    $routes->get('lampiran', 'Lampiran::index');

    J 1 Reply Last reply
    0
    • D darlina

      I'm trying to make an API of my application using CodeIgniter 4 (PHP, Javascript), but when I clicked Send(in postman) with URL: http://localhost:8080/lampiran, it always showing '404 Not Found'(The requested resource /lampiran was not found). This is my controller :

      class Lampiran extends ResourceController
      {
      protected $model = 'App\Models\lampiranModel';
      protected $format = 'json';

      public function index()
      {
          $data = \[
              'message' => 'success',
              'data\_lampiran' => $this->model->findAll()
          \];
          return $this->respond($data, 200);
      }
      

      .....

      and this is my route

      $routes->get('lampiran', 'Lampiran::index');

      J Offline
      J Offline
      Jeremy Falcon
      wrote on last edited by
      #2

      It sounds like you have a web server running by the nature of your error message, so it's probably a routing issue. Some MVC frameworks will do this automatically, but gonna assume that CodeIgniter doesn't. Both have their pros and cons... Anyway, here ya go... [URI Routing — CodeIgniter 4.5.5 documentation](https://codeigniter4.github.io/userguide/incoming/routing.html)

      Jeremy Falcon

      D 1 Reply Last reply
      0
      • J Jeremy Falcon

        It sounds like you have a web server running by the nature of your error message, so it's probably a routing issue. Some MVC frameworks will do this automatically, but gonna assume that CodeIgniter doesn't. Both have their pros and cons... Anyway, here ya go... [URI Routing — CodeIgniter 4.5.5 documentation](https://codeigniter4.github.io/userguide/incoming/routing.html)

        Jeremy Falcon

        D Offline
        D Offline
        darlina
        wrote on last edited by
        #3

        Thanks for the answer. You are right, it is routing problem. My first applicatoin can run with "localhost:8080/index.php/lampiran", and then I built another application from scratch, and it run with "localhost:8080/lampiran".

        1 Reply Last reply
        0
        Reply
        • Reply as topic
        Log in to reply
        • Oldest to Newest
        • Newest to Oldest
        • Most Votes


        • Login

        • Don't have an account? Register

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • World
        • Users
        • Groups