The server only receives GET requests when connecting from android with HttpsUrlConnection, even if it forces the POST connection

0

First of all, to greet the community in general, I am new to this platform. I have seen several related threads, in this and other forums, with the problem that is busting my mind: ** The server (API RESTFul in PHP) only receives GET requests using the HttpsUrlConnection of Android *.

The API responds well in terms of the type of requests, I have tried several clients (restlet client, insomnia, etc) and it works, but with the android app the server always receives GET and acts accordingly. This is the fragment of code that I use, which I have reduced to the minimum to test and force the POST:

        URL url = new URL("https://direccion");
        HttpsURLConnection conn = (HttpsURLConnection) url.openConnection();

        conn.setDoOutput(true);
        conn.setRequestMethod("POST");
        conn.setReadTimeout(10000);
        conn.setConnectTimeout(15000);
        conn.getOutputStream();
        OutputStream output = conn.getOutputStream();
        output.write(conn.getResponseCode());

Debugging the APP I have observed that the object of the HTTPS connection has the parameter Method="Get" and setDoOutput = false and never change, although the object delegate httpUrlConnection if it has the POST value and True for setDoOutPut. Screenshot of the Debug:

If anyone has any idea what may be happening, or if there is some way to implement a solution (I tried to extend httpsURLconnection to overwrite setRequestMethod, but it was more confusing). Thanks and Regards.

    
asked by José Ginés Giménez 25.10.2018 в 16:38
source

0 answers