Testing RESTful API (Lumen) - is the http/https protocol the problem? - php

I'm following this tutorial https://www.youtube.com/watch?v=6Oxfb_HNY0U
to build a small lumen testproject.
I'm currently at 27th minute where you are supposed to insert a record through a post request.
To do this, I'm using RESTClient http://restclient.net/
So, the last day I already did my best to tackle this problem, and thanks to SO I also could at least
in part solve the issue:
What does the second paremeter in "json()" do (Lumen/Laravel)?
However, I still get errors instead of new records.
When sending a post request to
http://localhost:8080/api/articles
I get this error:
(1/1) BadMethodCallException
Method Laravel\Lumen\Http\Request::validate does not exist.
in Macroable.php line 103
at Request->__call('validate', array(array('title' => 'required', 'description' => 'required')))in ArticleController.php line 36
at ArticleController->create(object(Request))
at call_user_func_array(array(object(ArticleController), 'create'), array(object(Request)))in BoundMethod.php line 32
at BoundMethod::Illuminate\Container\{closure}()in Util.php line 34
at Util::unwrapIfClosure(object(Closure))in BoundMethod.php line 90
at BoundMethod::callBoundMethod(object(Application), array(object(ArticleController), 'create'), object(Closure))in BoundMethod.php line 34
at BoundMethod::call(object(Application), array(object(ArticleController), 'create'), array(), null)in Container.php line 590
at Container->call(array(object(ArticleController), 'create'), array())in RoutesRequests.php line 376
at Application->callControllerCallable(array(object(ArticleController), 'create'), array())in RoutesRequests.php line 342
at Application->callLumenController(object(ArticleController), 'create', array(true, array('uses' => 'App\\Http\\Controllers\\ArticleController#create'), array()))in RoutesRequests.php line 316
at Application->callControllerAction(array(true, array('uses' => 'App\\Http\\Controllers\\ArticleController#create'), array()))in RoutesRequests.php line 278
at Application->callActionOnArrayBasedRoute(array(true, array('uses' => 'App\\Http\\Controllers\\ArticleController#create'), array()))in RoutesRequests.php line 263
at Application->handleFoundRoute(array(true, array('uses' => 'App\\Http\\Controllers\\ArticleController#create'), array()))in RoutesRequests.php line 165
at Application->Laravel\Lumen\Concerns\{closure}(object(Request))in RoutesRequests.php line 416
at Application->sendThroughPipeline(array(), object(Closure))in RoutesRequests.php line 171
at Application->dispatch(null)in RoutesRequests.php line 108
at Application->run()in index.php line 28
Since I'm new to Lumen/Laravel, I find it hard to guess anything from this error.
I don't know if I just mispelled something, didn't pay attention to scope or anything like that.
Now, here is the code which produced this error:
web.php (routes), Article.php (the model, residing in app folder) and ArticleController.php (Controller):
web.php:
<?php
/*
|--------------------------------------------------------------------------
| Application Routes
|--------------------------------------------------------------------------
|
| Here is where you can register all of the routes for an application.
| It is a breeze. Simply tell Lumen the URIs it should respond to
| and give it the Closure to call when that URI is requested.
|
*/
$router->get('/', function () use ($router) {
return $router->app->version();
});
// was simply 'api' in tutorial
$router->group(['prefix' => '/api'], function($router){
$router->get('articles', 'ArticleController#showAllArticles');
$router->get('articles/{id}', 'ArticleController#showOneArticle');
$router->post('articles', 'ArticleController#create');
});
ArticleController.php
<?php
namespace App\Http\Controllers;
use App\Article;
use Illuminate\Http\Request;
class ArticleController extends Controller
{
/**
* Create a new controller instance.
*
* #return void
*/
public function __construct()
{
//
}
//
public function showAllArticles(){
return response()->json(Article::get(['title', 'description', 'status'])); // ::get([]) spezifiziert die zu referenzierenden Attribute
// ::all() referenziert alle Attribute einer Tabelle/Relation
}
public function showOneArticle($id){
return response()->json(Article::find($id));
}
public function create(Request $request){
//dd($request); //for debugging whether the request is actually being processed
$validatedData = $request->validate([
'title' => 'required',
'description' => 'required',
]);
//dd($request); //for debugging whether the specified fields are required
//insert record
$article = Article::create($request->all());
return response()->json($article, 201);
}
}
Article.php:
<?php
namespace App;
use Illuminate\Database\Eloquent\Model;
class Article extends Model
{
protected $fillable = [
'title', 'description', 'status'
];
}
Since the function "create()" in this code is modified compared to the tutorial code (see the answer of ege in the SO question referenced at the top), I tried out the tutorial code as well, where the create() function looks like this:
public function create(Request $request){
$this->validation($request, [
'title' => 'required',
'description' => 'required'
]);
$article = Article::create($request->all());
return response()->json($article, 201);
}
and I get another error, in this case:
(1/1) Error
Call to undefined method App\Http\Controllers\ArticleController::validation()
in ArticleController.php line 41
at ArticleController->create(object(Request))
at call_user_func_array(array(object(ArticleController), 'create'), array(object(Request)))in BoundMethod.php line 32
at BoundMethod::Illuminate\Container\{closure}()in Util.php line 34
at Util::unwrapIfClosure(object(Closure))in BoundMethod.php line 90
at BoundMethod::callBoundMethod(object(Application), array(object(ArticleController), 'create'), object(Closure))in BoundMethod.php line 34
at BoundMethod::call(object(Application), array(object(ArticleController), 'create'), array(), null)in Container.php line 590
at Container->call(array(object(ArticleController), 'create'), array())in RoutesRequests.php line 376
at Application->callControllerCallable(array(object(ArticleController), 'create'), array())in RoutesRequests.php line 342
at Application->callLumenController(object(ArticleController), 'create', array(true, array('uses' => 'App\\Http\\Controllers\\ArticleController#create'), array()))in RoutesRequests.php line 316
at Application->callControllerAction(array(true, array('uses' => 'App\\Http\\Controllers\\ArticleController#create'), array()))in RoutesRequests.php line 278
at Application->callActionOnArrayBasedRoute(array(true, array('uses' => 'App\\Http\\Controllers\\ArticleController#create'), array()))in RoutesRequests.php line 263
at Application->handleFoundRoute(array(true, array('uses' => 'App\\Http\\Controllers\\ArticleController#create'), array()))in RoutesRequests.php line 165
at Application->Laravel\Lumen\Concerns\{closure}(object(Request))in RoutesRequests.php line 416
at Application->sendThroughPipeline(array(), object(Closure))in RoutesRequests.php line 171
at Application->dispatch(null)in RoutesRequests.php line 108
at Application->run()in index.php line 28
I'm basically having the same problems with understanding the error as with first error.
I've looked up the lumen documentation here:
https://lumen.laravel.com/docs/6.x/validation
And again I wonder if I didn't understand the scope correctly (what does "this" refer to here, what object is it, what methods can I actually call from it?).
For the sake of completeness, a screenshot of the table I'm referencing with the eloquent model "Article":
https://imgur.com/onXEgzg
Overall I'm just pretty clueless and I would be really thankful if someone could "give me a lift" ^^

Looking at your modified example (2nd version here of your create() method), The first line of the error shows the problem:
Call to undefined method App\Http\Controllers\ArticleController::validation()
So something is wrong with this line in your code:
$this->validation() ...
Checking the link to the Lumen docs that you include:
The $this->validate helper which is available in Lumen ...
So there is a validate() helper - but you're using validation().

Related

Laravel - firstOrCreate() detects argument 1 as non-array, but it is

I have the following code:
$coretable = new coretable;
$coretableKeyArray = [];
$coretableKeyArray["Internal_key"] = $coretableInput["Internal_key"];
if(is_array($coretableKeyArray)){
log::info("recognized as array");
}
$lastInsert = $coretable->firstOrCreate($coretableKeyArray, $coretableInput);
The array for argument 1 of firstOrCreate() looks like this:
[2020-02-27 07:30:50] local.INFO: array (
'Internal_key' => 'TESTKEY_4',
)
the is_array() also returns true on $coretableKeyArray
However, when doing the call to firstOrCreate() here:
$lastInsert = $coretable->firstOrCreate($coretableKeyArray, $coretableInput);
I get this error:
(1/1) TypeError
Argument 1 passed to Illuminate\Database\Eloquent\Builder::firstOrCreate() must be of the type array, int given, called in E:\aether-backend\vendor\illuminate\support\Traits\ForwardsCalls.php on line 23
in Builder.php line 415
at Builder->firstOrCreate(4, array('coretable_id' => 4, 'description_itc' => 'EXTENSION_ITC_4'))in ForwardsCalls.php line 23
at Model->forwardCallTo(object(Builder), 'firstOrCreate', array(4, array('coretable_id' => 4, 'description_itc' => 'EXTENSION_ITC_4')))in Model.php line 1618
at Model->__call('firstOrCreate', array(4, array('coretable_id' => 4, 'description_itc' => 'EXTENSION_ITC_4')))in modelInteractions.php line 128
Why is that? Also, why does the log of the error show me:
Builder->firstOrCreate(4, array('coretable_id' => 4, 'description_itc' => 'EXTENSION_ITC_4'))
Why is the first argument "4" here? What does it represent? Because it cant represent the value of the first argument of the call to firstOrCreate() because that was an entirely different one...
EDIT:
Here is the full errorstack, as requested per comment:
(1/1) TypeError
Argument 1 passed to Illuminate\Database\Eloquent\Builder::firstOrCreate() must be of the type array, int given, called in E:\aether-backend\vendor\illuminate\support\Traits\ForwardsCalls.php on line 23
in Builder.php line 415
at Builder->firstOrCreate(4, array('coretable_id' => 4, 'description_itc' => 'EXTENSION_ITC_4'))in ForwardsCalls.php line 23
at Model->forwardCallTo(object(Builder), 'firstOrCreate', array(4, array('coretable_id' => 4, 'description_itc' => 'EXTENSION_ITC_4')))in Model.php line 1618
at Model->__call('firstOrCreate', array(4, array('coretable_id' => 4, 'description_itc' => 'EXTENSION_ITC_4')))in modelInteractions.php line 127
at modelInteractions->insertModel(array('Internal_key' => 'TESTKEY_4'), array('Internal_key' => 'TESTKEY_4', 'extensiontable_itc' => array('description_itc' => 'EXTENSION_ITC_4'), 'extensiontable_sysops' => array('description_sysops' => 'EXTENSION_SYSOPS_4')), array('extensiontable_itc', 'extensiontable_sysops'))in UserController.php line 100
at UserController->insertDataCreateNewItem(object(Request))
at call_user_func_array(array(object(UserController), 'insertDataCreateNewItem'), array(object(Request)))in BoundMethod.php line 32
at BoundMethod::Illuminate\Container\{closure}()in Util.php line 36
at Util::unwrapIfClosure(object(Closure))in BoundMethod.php line 90
at BoundMethod::callBoundMethod(object(Application), array(object(UserController), 'insertDataCreateNewItem'), object(Closure))in BoundMethod.php line 34
at BoundMethod::call(object(Application), array(object(UserController), 'insertDataCreateNewItem'), array(), null)in Container.php line 590
at Container->call(array(object(UserController), 'insertDataCreateNewItem'), array())in RoutesRequests.php line 376
at Application->callControllerCallable(array(object(UserController), 'insertDataCreateNewItem'), array())in RoutesRequests.php line 342
at Application->callLumenController(object(UserController), 'insertDataCreateNewItem', array(true, array('uses' => 'App\\Http\\Controllers\\UserController#insertDataCreateNewItem', 'middleware' => array('auth')), array()))in RoutesRequests.php line 316
at Application->callControllerAction(array(true, array('uses' => 'App\\Http\\Controllers\\UserController#insertDataCreateNewItem', 'middleware' => array('auth')), array()))in RoutesRequests.php line 278
at Application->callActionOnArrayBasedRoute(array(true, array('uses' => 'App\\Http\\Controllers\\UserController#insertDataCreateNewItem', 'middleware' => array('auth')), array()))in RoutesRequests.php line 258
at Application->Laravel\Lumen\Concerns\{closure}(object(Request))
at call_user_func(object(Closure), object(Request))in Pipeline.php line 52
at Pipeline->Laravel\Lumen\Routing\{closure}(object(Request))in Authenticate.php line 36
at Authenticate->handle(object(Request), object(Closure))in Pipeline.php line 171
at Pipeline->Illuminate\Pipeline\{closure}(object(Request))
at call_user_func(object(Closure), object(Request))in Pipeline.php line 32
at Pipeline->Laravel\Lumen\Routing\{closure}(object(Request))in Pipeline.php line 105
at Pipeline->then(object(Closure))in RoutesRequests.php line 413
at Application->sendThroughPipeline(array('App\\Http\\Middleware\\Authenticate'), object(Closure))in RoutesRequests.php line 259
at Application->handleFoundRoute(array(true, array('uses' => 'App\\Http\\Controllers\\UserController#insertDataCreateNewItem', 'middleware' => array('auth')), array()))in RoutesRequests.php line 165
at Application->Laravel\Lumen\Concerns\{closure}(object(Request))
at call_user_func(object(Closure), object(Request))in Pipeline.php line 52
at Pipeline->Laravel\Lumen\Routing\{closure}(object(Request))in CORS.php line 34
at CORS->handle(object(Request), object(Closure))in Pipeline.php line 171
at Pipeline->Illuminate\Pipeline\{closure}(object(Request))
at call_user_func(object(Closure), object(Request))in Pipeline.php line 32
at Pipeline->Laravel\Lumen\Routing\{closure}(object(Request))in Pipeline.php line 105
at Pipeline->then(object(Closure))in RoutesRequests.php line 413
at Application->sendThroughPipeline(array('App\\Http\\Middleware\\CORS'), object(Closure))in RoutesRequests.php line 171
at Application->dispatch(null)in RoutesRequests.php line 108
at Application->run()in index.php line 28
EDIT:
Question can be closed or deleted, the solution to the problem was somewhere else.
Try this:
$lastInsert = $coretable->firstOrCreate((array)$coretableKeyArray, $coretableInput);
If that doesn't work, in case you've overloaded firstOrCreate make sure it doesn't do custom casts within it.
Instead of storing in a variable you can directly put it in the method.
Much cleaner and also readable.
$coretable->firstOrCreate([
'Internal_key' => $coretableInput["Internal_key"]
], $coretableInput);

Cakephp Plugin prefix not working

I'm creating a Cakephp(3.5.14) plugin, it is working fine with the below given routes
plugins/timesheet/config/routes.php
Router::plugin(
'Timesheet', ['path' => '/timesheets'], function (RouteBuilder $routes) {
$routes->setExtensions(['json']);
$routes->connect('/', ['controller' => 'Timesheets', 'action' => 'index']);
$routes->connect('/edit', ['controller' => 'Timesheets', 'action' => 'edit']);
$routes->connect('/add', ['controller' => 'Timesheets', 'action' => 'add']);
$routes->fallbacks(DashedRoute::class);
as per the documentation this I added in
project src/config/routes.php
$routes->scope('/backend', function ($routes) {
$routes->loadPlugin('Timesheet');
});
BUt somehow, it's not working.
My URL: www.xxx.com/backend/timesheets
Error: BackendController could not be found.
In the case you tried to access a plugin controller make sure you added it to your composer file or you use the autoload option for the plugin.
Error: Create the class BackendController below in file: src\Controller\BackendController.php
use App\Controller\AppController;
class BackendController extends AppController
{
}
Stack Trace:
⟩ Cake\Http\ControllerFactory->missingController
CORE\src\Http\ControllerFactory.php, line 38
⟩ Cake\Http\ControllerFactory->create
CORE\src\Http\ActionDispatcher.php, line 90
⟩ Cake\Http\ActionDispatcher->dispatch
CORE\src\Http\BaseApplication.php, line 108
⟩ Cake\Http\BaseApplication->__invoke
CORE\src\Http\Runner.php, line 65
⟩ Cake\Http\Runner->__invoke
CORE\src\Routing\Middleware\RoutingMiddleware.php, line 104
⟩ Cake\Routing\Middleware\RoutingMiddleware->__invoke
CORE\src\Http\Runner.php, line 65
⟩ Cake\Http\Runner->__invoke
CORE\src\Routing\Middleware\AssetMiddleware.php, line 88
⟩ Cake\Routing\Middleware\AssetMiddleware->__invoke
CORE\src\Http\Runner.php, line 65
⟩ Cake\Http\Runner->__invoke
CORE\src\Error\Middleware\ErrorHandlerMiddleware.php, line 98
⟩ Cake\Error\Middleware\ErrorHandlerMiddleware->__invoke
CORE\src\Http\Runner.php, line 65
⟩ Cake\Http\Runner->__invoke
ROOT\vendor\cakephp\debug_kit\src\Middleware\DebugKitMiddleware.php, line 52
⟩ DebugKit\Middleware\DebugKitMiddleware->__invoke
CORE\src\Http\Runner.php, line 65
⟩ Cake\Http\Runner->__invoke
CORE\src\Http\Runner.php, line 51
⟩ Cake\Http\Runner->run
CORE\src\Http\Server.php, line 81
⟩ Cake\Http\Server->run
ROOT\webroot\index.php, line 40
Thanks in advance.
Check the other routes that are connected in your application, there's most likely a route connected earlier that catches the request, probably one that looks for something like /:controller/:action (either explicitly, or as fallback routes), hence it uses the backend part as the controller.
You can easily get a list of all connected routes via the routes shell:
bin/cake routes

Facade error in laravel 5.2

I installed a package in Laravel 5.2 named jonnywilliamson/laragram
And put in config\app.php a alias and service provider like below :
'providers' => [
.
.
.,
Illuminate\Translation\TranslationServiceProvider::class,
Illuminate\Validation\ValidationServiceProvider::class,
Illuminate\View\ViewServiceProvider::class,
Williamson\Laragram\Laravel\LaragramServiceProvider::class,
]
'aliases' => [
.
.
.,
'URL' => Illuminate\Support\Facades\URL::class,
'Validator' => Illuminate\Support\Facades\Validator::class,
'View' => Illuminate\Support\Facades\View::class,
'TG' => Williamson\Laragram\Laravel\LaragramFacade::class,
]
And in my contoller :
use TG;
public function test()
{
return TG::sendMsg('+989118000000', 'Hello there!');
}
And route:
Route::get('test', 'Services\Auth\Controller\v1_0\AuthController#test');
I also run the following commands :
composer dumpautoload
composer dumpautoload -o
php artisan cache:clear
php artisan clear-compiled
php artisan optimize
But still shows error like:
RuntimeException in Facade.php line 210:
A facade root has not been set.
in Facade.php line 210
at Facade::__callStatic('sendMsg', array('+989118000217', 'Hello there!')) in User.php line 68
at LaragramFacade::sendMsg('+989118000217', 'Hello there!') in User.php line 68
at AuthController->test('fa')
at call_user_func_array(array(object(AuthController), 'test'), array('lang' => 'fa')) in Controller.php line 80
at Controller->callAction('test', array('lang' => 'fa')) in ControllerDispatcher.php line 146
at ControllerDispatcher->call(object(AuthController), object(Route), 'test') in ControllerDispatcher.php line 94
at ControllerDispatcher->Illuminate\Routing\{closure}(object(Request))
How can i fix it?
The function you are trying to call is called sendMessage:
return TG::sendMessage('+989118000000', 'Hello there!');
You are using sendMsg, which is causing the error.

Lumen - Class url does not exist

I am using Lumen to create a website, and while my controllers, routes, and views are well configured, I get an error when I try to use the redirect function in a controller.
This is the error code :
ReflectionException in Container.php line 736: Class url does not exist
in Container.php line 736
at ReflectionClass->__construct('url') in Container.php line 736
at Container->build('url', array()) in Container.php line 631
at Container->make('url', array()) in Application.php line 203
at Application->make('url') in Redirector.php line 39
at Redirector->to('http://opentracker.local/token/archived', '302', array(), null) in helpers.php line 246
at redirect('http://opentracker.local/token/archived') in TokenController.php line 51
at TokenController->unarchive('clickid')
at call_user_func_array(array(object(TokenController), 'unarchive'), array('clickid')) in Container.php line 507
at Container->call(array(object(TokenController), 'unarchive'), array('attribute' => 'clickid')) in RoutesRequests.php line 567
at Application->callControllerCallable(array(object(TokenController), 'unarchive'), array('attribute' => 'clickid')) in RoutesRequests.php line 534
at Application->callLumenController(object(TokenController), 'unarchive', array('1', array('as' => 'token.unarchive', 'uses' => 'App\Http\Controllers\TokenController#unarchive'), array('attribute' => 'clickid'))) in RoutesRequests.php line 507
at Application->callControllerAction(array('1', array('as' => 'token.unarchive', 'uses' => 'App\Http\Controllers\TokenController#unarchive'), array('attribute' => 'clickid'))) in RoutesRequests.php line 475
at Application->callActionOnArrayBasedRoute(array('1', array('as' => 'token.unarchive', 'uses' => 'App\Http\Controllers\TokenController#unarchive'), array('attribute' => 'clickid'))) in RoutesRequests.php line 460
at Application->handleFoundRoute(array('1', array('as' => 'token.unarchive', 'uses' => 'App\Http\Controllers\TokenController#unarchive'), array('attribute' => 'clickid'))) in RoutesRequests.php line 434
at Application->handleDispatcherResponse(array('1', array('as' => 'token.unarchive', 'uses' => 'App\Http\Controllers\TokenController#unarchive'), array('attribute' => 'clickid'))) in RoutesRequests.php line 367
at Application->Laravel\Lumen\Concerns\{closure}() in RoutesRequests.php line 610
at Application->sendThroughPipeline(array(), object(Closure)) in RoutesRequests.php line 368
at Application->dispatch(null) in RoutesRequests.php line 313
at Application->run() in index.php line 28
My route is well recognized, (you can see it transformed as it should in the error).
Here is the code that I use in my controller :
public function unarchive($attribute){
Token::query()->find($attribute)->update(['is_archived'=>0]);
return redirect(route('token.archived'));
}
I also uncommented the following from boostrap/app.php :
$app->withFacades();
$app->withEloquent();
Is there a problem using the function redirect() with Lumen ? I tried both redirect(route()) and redirect()->route(), and they gave the same result.
If you are on 5.2 there is an issue open for this.
Lumen - Github Issues - redirect() doesn't work, Lumen 5.2 #315
You can use the Illuminate\Http\RedirectResponse directly if needed. (from workaround link below):
return new RedirectResponse('login');
return RedirectResponse::create('login');
Possible workaround from Github Issue

Laravel 5 Token mismatch on POST request

It is appening something that is very strange:
I'm implementing in Laravel 5, the Iron message queue in order to differ the request, from long tasks executions.
Once I've pushed a message into the Iron's queue, it sends a POST request to a predefined route, in order to wake up the long running process (Push Queue approach).
I've this route file:
Route::post('queue/receive', function()
{
//start long task exec
return Queue::marshal();
});
/* garantisco il logout agli utenti*/
Route::get('auth/logout', 'Auth\AuthController#getLogout');
/* redirect degli utenti loggati */
Route::group(['middleware' => 'guest'], function()
{
Route::get('/', 'WelcomeController#index');
Route::controllers([
'auth' => 'Auth\AuthController',
'password' => 'Auth\PasswordController',
]);
});
Route::group(['middleware' => 'auth'], function()
{
Route::get('home', 'HomeController#index');
});
The first route defined is the endpoint that IronMQ will call.
I know that token mismatch is a popular problem using the "VerifyCsrfToken" middleware (same as filter in L4).
The incredible thing is that I've disabled this middleware, but the problem persists.
This is my kernel's middlewares:
class Kernel extends HttpKernel {
/**
* The application's global HTTP middleware stack.
*
* #var array
*/
protected $middleware = [
'Illuminate\Foundation\Http\Middleware\CheckForMaintenanceMode',
'Illuminate\Cookie\Middleware\EncryptCookies',
'Illuminate\Cookie\Middleware\AddQueuedCookiesToResponse',
'Illuminate\Session\Middleware\StartSession',
'Illuminate\View\Middleware\ShareErrorsFromSession',
//'LabelCreator\Http\Middleware\VerifyCsrfToken',
];
/**
* The application's route middleware.
*
* #var array
*/
protected $routeMiddleware = [
'auth' => 'LabelCreator\Http\Middleware\Authenticate',
'auth.basic' => 'Illuminate\Auth\Middleware\AuthenticateWithBasicAuth',
'guest' => 'LabelCreator\Http\Middleware\RedirectIfAuthenticated',
];
}
As you can see, "VerifyCsrfToken" is disabled but testing the post request from local env, now I'm getting this error:
DecryptException in Encrypter.php line 142:
Invalid data.
in Encrypter.php line 142
at Encrypter->getJsonPayload('') in Encrypter.php line 92
at Encrypter->decrypt('') in IronQueue.php line 214
at IronQueue->parseJobBody('') in IronQueue.php line 173
at IronQueue->marshalPushedJob() in IronQueue.php line 159
at IronQueue->marshal()
at call_user_func_array(array(object(IronQueue), 'marshal'), array()) in QueueManager.php line 223
at QueueManager->__call('marshal', array()) in Facade.php line 207
at QueueManager->marshal() in Facade.php line 207
at Facade::__callStatic('marshal', array()) in routes.php line 17
at Queue::marshal() in routes.php line 17
at RouteServiceProvider->{closure}()
at call_user_func_array(object(Closure), array()) in Route.php line 153
at Route->runCallable(object(Request)) in Route.php line 128
at Route->run(object(Request)) in Router.php line 691
at Router->Illuminate\Routing\{closure}(object(Request))
at call_user_func(object(Closure), object(Request)) in Pipeline.php line 141
at Pipeline->Illuminate\Pipeline\{closure}(object(Request))
at call_user_func(object(Closure), object(Request)) in Pipeline.php line 101
at Pipeline->then(object(Closure)) in Router.php line 693
at Router->runRouteWithinStack(object(Route), object(Request)) in Router.php line 660
at Router->dispatchToRoute(object(Request)) in Router.php line 618
at Router->dispatch(object(Request)) in Kernel.php line 210
at Kernel->Illuminate\Foundation\Http\{closure}(object(Request))
at call_user_func(object(Closure), object(Request)) in Pipeline.php line 141
at Pipeline->Illuminate\Pipeline\{closure}(object(Request)) in ShareErrorsFromSession.php line 55
at ShareErrorsFromSession->handle(object(Request), object(Closure)) in Pipeline.php line 125
at Pipeline->Illuminate\Pipeline\{closure}(object(Request)) in StartSession.php line 61
at StartSession->handle(object(Request), object(Closure)) in Pipeline.php line 125
at Pipeline->Illuminate\Pipeline\{closure}(object(Request)) in AddQueuedCookiesToResponse.php line 36
at AddQueuedCookiesToResponse->handle(object(Request), object(Closure)) in Pipeline.php line 125
at Pipeline->Illuminate\Pipeline\{closure}(object(Request)) in EncryptCookies.php line 40
at EncryptCookies->handle(object(Request), object(Closure)) in Pipeline.php line 125
at Pipeline->Illuminate\Pipeline\{closure}(object(Request)) in CheckForMaintenanceMode.php line 42
at CheckForMaintenanceMode->handle(object(Request), object(Closure)) in Pipeline.php line 125
at Pipeline->Illuminate\Pipeline\{closure}(object(Request))
at call_user_func(object(Closure), object(Request)) in Pipeline.php line 101
at Pipeline->then(object(Closure)) in Kernel.php line 111
at Kernel->sendRequestThroughRouter(object(Request)) in Kernel.php line 84
at Kernel->handle(object(Request)) in index.php line 53
I've tried to comment the others middlewares, but the problem persists.
What Iron is doing is a simple POST request to my endpoint, like webhooks do.
What is the problem?
I don't think is a session's problem, because Iron is a simple thirdy part service that call an endpoint, and if it remains a "guest" client for my app it is ok.
Can anyone help me?
thanks in advance
I've found the problem:
I was testing the endpoint in local without a POST request payload, so the decryption doesn't work properly, but sniffing which payload IronMQ sends, using RequestBin (very useful tool), I've added the same payload to local test request, and now it works.
Hope it helps :)

Categories