Hi im doing both android and laravel framework.. but when i do post method and send json to laravel api via POST.. it will give a 500 result.. please help..
this is one of my asynctask in android sending the post data.. assume 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 framework.. 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 a 500 response code from Laravel api.. i want it to read the json data.. and send it back.. if i used Mozilla plugin rest client, and send the json data in body.. it gives 200..