L
L
leha782016-09-18 09:45:02
Android
leha78, 2016-09-18 09:45:02

HttpClient not sending POST data to server?

private void registerToken(String token) {
        Log.d("MyToken", "Refreshed token: " + token);
        OkHttpClient client = new OkHttpClient();
        RequestBody body = new FormBody.Builder()
                .add("token","tokenn")
                .build();

        Request request = new Request.Builder()
                .url("http://site.ru/site/devices/")
                .post(body)
                .build();

        try {

            client.newCall(request).execute();
        } catch (IOException e) {
            e.printStackTrace();
        }
    }

public function actionDevices ()
    {
    	// if (null != Yii::$app->request->post('token'))
    	// {
     		
    		$model = new Android();
    		$model->token = 'test_token';
    		$model->save();

    	// }

    	die('devices');
    }

The Android application sends a request to the server, the actionDevices method is triggered on the server and writes the test token to the database. But the POST method does not receive data from the application. Why is this happening?
UPD. It turns out that the data is coming, but it does not accept it on the side of the engine. I will sort this out.

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question