Found a solution for this?
Laravel 5.1 returns 500 error when called by Guzzle (5.3/6.0)
I have created a very simple API with L5.1, something along the lines of:
use Api\Models\Contact;
Route::get('api/contacts', function() {
return Contact::all();
});
I will call this APIONE. The URI from APIONE returns correct json to the browser and via curl request on the command line. However, when calling from another app with Guzzle (with all 5.2, 5.3 & 6.0) I get an Internal Server 500. I have another VERY similar API app built on L4.2, let's call this APITWO and when called via Guzzle (5.3 &OR 6.0) it returns correct json to my API consuming app leading me to conclude that this is a problem / change with how L5.1 handles outside requests.
Anyone experiencing similar or know something about Laravel 5.1 I dont? Thanks
It might be some CSRF issue.
Laravel 4.2 did not have middlewares, and on 5.1 the CSRF middleware is "on" by default. Since your code works on the browser and curl but not from another app it might be some issue with that.
Just disable the CSRF middleware to be sure (go to App->Http->Kernel and remove 'App\Http\Middleware\VerifyCsrfToken' from the $middleware array)
ps.: If this is the error that might not be the best solution to your use case. You might want to generate a csrf_token on your client and send it on the request.
Please or to participate in this conversation.