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
android php laravel


source to share


No one has answered this question yet

Check out similar questions:

3295
Why is the Android emulator so slow? How can we speed up the development of an Android emulator?
2510
How to persist android activity state by persisting instance state?
850
Determining the type of request in PHP (GET, POST, PUT or DELETE)
809
How to send an object from one android activity to another using intents?
615
How do I send a POST request from PHP?
3
Android POST request with JSON
0
Empty request when calling Laravel with Android Volley
0
Using HttpURLConnection to send JSON post request in Android
0
Android | Send "POST" JSON data to server
0
Sending a parameterized HTTP POST request from Android



All Articles
Loading...
X
Show
Funny
Dev
Pics