mardi 23 août 2016

Sending POST request from android to RoR app, but cannot find the right URL

I am not able to reach the create Method in tests_controller.rb with this code.

String newUrl = "http://ift.tt/2bseNRw";

        httpcon = (HttpURLConnection) ((new URL(newUrl).openConnection()));
        httpcon.setDoOutput(true);
        httpcon.setRequestProperty("Content-Type", "application/json");
        httpcon.setRequestProperty("Accept", "application/json");
        httpcon.setRequestMethod("POST");
        httpcon.connect();

And here is my routes.rb (I use model scaffold to create the RoR app).

resources :tests

Am i wrong in routing or something. When i run this code in Android, the create method is not run at all.

Aucun commentaire:

Enregistrer un commentaire