how to set request header for sending data from android apps to our server

后端 未结 4 1045
佛祖请我去吃肉
佛祖请我去吃肉 2020-12-30 12:33

How to set http header to sending json object from our android apps what type of header we want to use for sending data from client side to server.why we ar

4条回答
  •  礼貌的吻别
    2020-12-30 13:15

    you can use

    try {
                HttpClient client = new DefaultHttpClient();  
                String getURL = "http://helloworld.com/getmethod.aspx?id=1&method=getData";
                HttpGet httpGet = new HttpGet(getURL);
                **httpGet .setHeader("Content-Type", "application/x-zip");**
                HttpResponse response = client.execute(httpGet);  
                HttpEntity resEntity = response.getEntity();  
                if (resEntity != null) {  
                            //parse response.
                            Log.e("Response",EntityUtils.toString(resEntity));
                        }
        } catch (Exception e) {
            e.printStackTrace();
        }
    

提交回复
热议问题