Forum

Ask, reply and learn. Join the community of Akaunting.

New Discussion

Dingo API routing issue

Gopal Rathod   ( User )

Commented 5 years ago

Hello,


I am facing some issues into dingo API


when i get or post data of Customers/Items and its work at when i develop the code but after i clear :cache its give me below error. some times it automatically working and some times it not work.


--


i folllow links:
https://github.com/dingo/api/wiki/Creating-API-Endpoints


php artisan cache:clear
php artisan route:cache
php artisan api:cache
php artisan clear-compiled


After Excute above commands. some times its work. but i did not find real issue.


POST >>  common/items  >>  items.store >>  App\Http\Controllers\Common\Items@store
GET|HEAD >> common/items >> items.index  >> App\Http\Controllers\Common\Items@index 


 


<code>


$url = "http://localhost/Akaunting134Stable/api/items?company_id=1";
$data = [];   
$email = '[email protected]';
$password = '123456';

//$url_param = http_build_query($data);   
$ch = curl_init($url);
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'GET');
//curl_setopt($ch, CURLOPT_POSTFIELDS, $url_param);
//curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-Type: application/json',                    
                'authorization: Basic '.base64_encode("$email:$password"),                   
                'cache-control: no-cache',
                'email: '.$email,
                'password: '.$password,
                ));
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER , false);
#curl_setopt($ch, CURLOPT_HTTP_VERSION , 'CURL_HTTP_VERSION_1_1');
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false);         
$result = curl_exec($ch);
print_r($result);
if (curl_error($ch)) {
    $error_msg = curl_error($ch);
    print_r($error_msg);
}else{
   
}
curl_close($ch);


 


#Response:


{"message":"404 Not Found","status_code":404,"debug":{"line":179,"file":"D:\\wamp64\\www\\Akaunting134Stable\\vendor\\laravel\\framework\\src\\Illuminate\\Routing\\RouteCollection.php","class":"Symfony\\Component\\HttpKernel\\Exception\\NotFoundHttpException","trace":["#0 D:\\wamp64\\www\\Akaunting134Stable\\vendor\\laravel\\framework\\src\\Illuminate\\Routing\\Router.php(546): Illuminate\\Routing\\RouteCollection->match(Object(Dingo\\Api\\Http\\Request))","#1 D:\\wamp64\\www\\Akaunting134Stable\\vendor\\laravel\\framework\\src\\Illuminate\\Routing\\Router.php(525): Illuminate\\Routing\\Router->findRoute(Object(Dingo\\Api\\Http\\Request))","#2 D:\\wamp64\\www\\Akaunting134Stable\\vendor\\laravel\\framework\\src\\Illuminate\\Routing\\Router.php(511): Illuminate\\Routing\\Router->dispatchToRoute(Object(Dingo\\Api\\Http\\Request))","#3 D:\\wamp64\\www\\Akaunting134Stable\\vendor\\dingo\\api\\src\\Routing\\Adapter\\Laravel.php(81): Illuminate\\Routing\\Router->dispatch(Object(Dingo\\Api\\Http\\Request))","#4 D:\\wamp64\\www\\Akaunting134Stable\\vendor\\dingo\\api\\src\\Routing\\Router.php(513): Dingo\\Api\\Routing\\Adapter\\Laravel->dispatch(Object(Dingo\\Api\\Http\\Request), 'v1')","#5 D:\\wamp64\\www\\Akaunting134Stable\\vendor\\dingo\\api\\src\\Http\\Middleware\\Request.php(126): Dingo\\Api\\Routing\\Router->dispatch(Object(Dingo\\Api\\Http\\Request))","#6 D:\\wamp64\\www\\Akaunting134Stable\\vendor\\laravel\\framework\\src\\Illuminate\\Pipeline\\Pipeline.php(114): Dingo\\Api\\Http\\Middleware\\Request->Dingo\\Api\\Http\\Middleware\\{closure}(Object(Dingo\\Api\\Http\\Request))","#7 D:\\wamp64\\www\\Akaunting134Stable\\vendor\\fideloper\\proxy\\src\\TrustProxies.php(56): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}(Object(Dingo\\Api\\Http\\Request))","#8 D:\\wamp64\\www\\Akaunting134Stable\\vendor\\laravel\\framework\\src\\Illuminate\\Pipeline\\Pipeline.php(148): Fideloper\\Proxy\\TrustProxies->handle(Object(Dingo\\Api\\Http\\Request), Object(Closure))","#9 D:\\wamp64\\www\\Akaunting134Stable\\vendor\\laravel\\framework\\src\\Illuminate\\Foundation\\Http\\Middleware\\TransformsRequest.php(30): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}(Object(Dingo\\Api\\Http\\Request))","#10 D:\\wamp64\\www\\Akaunting134Stable\\vendor\\laravel\\framework\\src\\Illuminate\\Pipeline\\Pipeline.php(148): Illuminate\\Foundation\\Http\\Middleware\\TransformsRequest->handle(Object(Dingo\\Api\\Http\\Request), Object(Closure))","#11 D:\\wamp64\\www\\Akaunting134Stable\\vendor\\laravel\\framework\\src\\Illuminate\\Foundation\\Http\\Middleware\\TransformsRequest.php(30): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}(Object(Dingo\\Api\\Http\\Request))","#12 D:\\wamp64\\www\\Akaunting134Stable\\vendor\\laravel\\framework\\src\\Illuminate\\Pipeline\\Pipeline.php(148): Illuminate\\Foundation\\Http\\Middleware\\TransformsRequest->handle(Object(Dingo\\Api\\Http\\Request), Object(Closure))","#13 D:\\wamp64\\www\\Akaunting134Stable\\vendor\\laravel\\framework\\src\\Illuminate\\Foundation\\Http\\Middleware\\ValidatePostSize.php(27): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}(Object(Dingo\\Api\\Http\\Request))","#14 D:\\wamp64\\www\\Akaunting134Stable\\vendor\\laravel\\framework\\src\\Illuminate\\Pipeline\\Pipeline.php(148): Illuminate\\Foundation\\Http\\Middleware\\ValidatePostSize->handle(Object(Dingo\\Api\\Http\\Request), Object(Closure))","#15 D:\\wamp64\\www\\Akaunting134Stable\\vendor\\laravel\\framework\\src\\Illuminate\\Foundation\\Http\\Middleware\\CheckForMaintenanceMode.php(46): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}(Object(Dingo\\Api\\Http\\Request))","#16 D:\\wamp64\\www\\Akaunting134Stable\\vendor\\laravel\\framework\\src\\Illuminate\\Pipeline\\Pipeline.php(148): Illuminate\\Foundation\\Http\\Middleware\\CheckForMaintenanceMode->handle(Object(Dingo\\Api\\Http\\Request), Object(Closure))","#17 D:\\wamp64\\www\\Akaunting134Stable\\vendor\\laravel\\framework\\src\\Illuminate\\Pipeline\\Pipeline.php(102): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}(Object(Dingo\\Api\\Http\\Request))","#18 D:\\wamp64\\www\\Akaunting134Stable\\vendor\\dingo\\api\\src\\Http\\Middleware\\Request.php(127): Illuminate\\Pipeline\\Pipeline->then(Object(Closure))","#19 D:\\wamp64\\www\\Akaunting134Stable\\vendor\\dingo\\api\\src\\Http\\Middleware\\Request.php(103): Dingo\\Api\\Http\\Middleware\\Request->sendRequestThroughRouter(Object(Dingo\\Api\\Http\\Request))","#20 D:\\wamp64\\www\\Akaunting134Stable\\vendor\\laravel\\framework\\src\\Illuminate\\Pipeline\\Pipeline.php(148): Dingo\\Api\\Http\\Middleware\\Request->handle(Object(Illuminate\\Http\\Request), Object(Closure))","#21 D:\\wamp64\\www\\Akaunting134Stable\\vendor\\laravel\\framework\\src\\Illuminate\\Routing\\Pipeline.php(53): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}(Object(Illuminate\\Http\\Request))","#22 D:\\wamp64\\www\\Akaunting134Stable\\vendor\\laravel\\framework\\src\\Illuminate\\Pipeline\\Pipeline.php(102): Illuminate\\Routing\\Pipeline->Illuminate\\Routing\\{closure}(Object(Illuminate\\Http\\Request))","#23 D:\\wamp64\\www\\Akaunting134Stable\\vendor\\laravel\\framework\\src\\Illuminate\\Foundation\\Http\\Kernel.php(151): Illuminate\\Pipeline\\Pipeline->then(Object(Closure))","#24 D:\\wamp64\\www\\Akaunting134Stable\\vendor\\laravel\\framework\\src\\Illuminate\\Foundation\\Http\\Kernel.php(116): Illuminate\\Foundation\\Http\\Kernel->sendRequestThroughRouter(Object(Illuminate\\Http\\Request))","#25 D:\\wamp64\\www\\Akaunting134Stable\\index.php(28): Illuminate\\Foundation\\Http\\Kernel->handle(Object(Illuminate\\Http\\Request))","#26 {main}"]}}


1

Gopal Rathod   ( User )

Commented 5 years ago

When i execute command:


case1:  php artisan clear-compiled
    o/p -> {"message":"404 Not Found","status_code":404,"debug"....} Same as above


case2:  php artisan api:cache
  o/p -> Whoops, looks like something went wrong.

Gopal Rathod   ( User )

Commented 5 years ago

After deep R&D, issue have been solved.

Pooja Pooja   ( User )

Commented 6 months ago

How you fixed it?

Please login or register to leave a response.

Showing 1 to 4 of 4 discussions