mardi 28 mars 2017

Allow others to make a HTTP POST to your Laravel 5 App

I'm testing my post route right now because I need to allow this route to be posted by other application.

I declare my route like this :

Route::post('/api/obj/post', 'DashboardController@post');

I'm trying to post this data to my route via cURL

{"test":"123"}

curl -X POST -H "Content-Type:application/json" -d '{"test":"123"}' http://ift.tt/2nwuexN

Here is my controller function

public function post(){
    dd(Input::all()); <--------- I should see all the inputs that submit to me. Shouldn't I ?
}

I keep getting redirecting back to home page instead

<!DOCTYPE html>
<html>
    <head>
        <meta charset="UTF-8" />
        <meta http-equiv="refresh" content="1;url=http://127.0.0.1" />

        <title>Redirecting to http://ift.tt/2od9c5E;
    </head>
    <body>
        Redirecting to <a href="http://127.0.0.1">http://ift.tt/2nwDjXd;.
    </body>
</html>


Questions

How do I prevent that redirect, and instead grab those data and continue my tasks so on and so forth ?

How would one go about and debug this further ?


I'm opening to any suggestions at this moment.

Any hints / suggestions / helps on this be will be much appreciated !



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire