samsoft's avatar

Problem accessing Lumen API

Please help, i'm accessing lumen api from postman using the url below

http://192.168.1.11:80/laratest/api/public/api/v1/register

it display NotFoundHttpException in Application.php line 1116: The API address is the local IP using ipconfig.

$app->get('/', function() use ($app) {

    return $app->welcome();
//    return 'i got you!';

});


//api.studystudio.com.ng/i/v1/register
$app->group(['prefix' => 'api/v1'], function() use ($app)
{

    $app->post('register', function(){

        return response()->json(['message' => 'Unknown Data Attacked, Please try again later!', 'code' => 200], 200);
    });

    $app->post('activate', function()
    {

        $me = DB::table('systems')->get();
        //$id = DB::table('user')->insertGetId(['email' => 'john@example.com', 'votes' => 0]);
        //DB::table('users')->where('id', 1)->update(['votes' => 1]);

        dd($me);

    });

});

Please what can i do to access the API

0 likes
8 replies
samsoft's avatar

Thanks @Ruffles it work perfectly from the browser, i access it using localhost:8888/api/v1/register and i'll change the response()->json([]) to array and post to get to check if its working.

davorminchorov's avatar

use localhost:8888/api/v1/register when you want to access your API from postman.

davorminchorov's avatar

Ok so do you get anything when trying to access that URL from a different PC/Laptop/Phone browser?

samsoft's avatar

Yes... i got this

E/ERROR﹕ retrofit.RetrofitError: 404 Not Found

since i can't access it from postman, i'll be difficult for it to work inside the android application. is there anything i need to enable for this to work or is there anything wrong with me logic in route.php? Confused!

davorminchorov's avatar

Your API is not accessible from outside, you have to either:

  • fix the web server
  • fix the URL
samsoft's avatar

Solved the problem by changing the

$app->run();
in /public/index.php to

$request = Illuminate\Http\Request::capture();
$app->run($request);

Please or to participate in this conversation.