Android How to send POST request in Laravel Framework

Hi i am doing both android and laravel framework .. but when i do submit method and send json to laravel api via POST .. it gives 500 result. Please help ..

this is one of my asyntact in android sending post data. Let's say sendJsonObj is a jsonobject with values.

URL url = new URL("http://dexter-laravelframe.rhcloud.com/register");

        urlConnect = (HttpURLConnection) url.openConnection();
        urlConnect.setRequestMethod("POST");
        urlConnect.setConnectTimeout(10000);
        urlConnect.setRequestProperty("Content-Type", "application/json");
        urlConnect.setRequestProperty("x-csrf-token", Model_Application.token_csrf);
        urlConnect.connect();

        OutputStreamWriter outWrite = new OutputStreamWriter(urlConnect.getOutputStream());
        outWrite.write(sendJsonObj.toString());
        outWrite.flush();
        outWrite.close();

        int code = urlConnect.getResponseCode();`

      

on my Laravel base .. routes.php Route::post('/register', 'UserController@register');

UserController.php

public function register()
{
    $json = Input::json()->all();

    $resultJson = json_encode($json);

    echo $resultJson;

}

      

this will give 500 response code from Laravel api .. i want it to read json data .. and send it back .. if i used Mozilla plugin rest client and sent json data in body .. it gives 200 ..

+3


source to share





All Articles