Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>you need to set content type <code>"application/x-www-form-urlencoded"</code> in your request headers for the type of data you want to send.</p> <p>I tested your API for the above mentioned data, it is working fine and i received loads of data in response. You can find it <a href="http://pastebin.com/c3VEMQyx" rel="noreferrer">here</a>.</p> <p>You can try the following code:</p> <pre><code>public String postDataToServer(String url) throws Throwable { HttpPost request = new HttpPost(url); StringBuilder sb=new StringBuilder(); String requestData = prepareRequest(); StringEntity entity = new StringEntity(requestData); entity.setContentType("application/x-www-form-urlencoded;charset=UTF-8");//text/plain;charset=UTF-8 request.getParams().setParameter(CoreProtocolPNames.USE_EXPECT_CONTINUE, Boolean.FALSE); request.setHeader("Accept", "application/json"); request.setEntity(entity); // Send request to WCF service HttpResponse response =null; DefaultHttpClient httpClient = new DefaultHttpClient(); //DefaultHttpClient httpClient = getNewHttpClient(); HttpConnectionParams.setSoTimeout(httpClient.getParams(), 10*1000); HttpConnectionParams.setConnectionTimeout(httpClient.getParams(),10*1000); try{ response = httpClient.execute(request); } catch(SocketException se) { Log.e("SocketException", se+""); throw se; } /* Patch to prevent user from hitting the request twice by clicking * the view [button, link etc] twice. */ finally{ } InputStream in = response.getEntity().getContent(); BufferedReader reader = new BufferedReader(new InputStreamReader(in)); String line = null; while((line = reader.readLine()) != null){ sb.append(line); } Log.d("response in Post method", sb.toString()+""); return sb.toString(); } public String prepareRequest() { return "player=Zer0conf&amp;opt=all"; } </code></pre> <p><strong>Edit:</strong> I was getting error <strong>Expectation Failed error- 417</strong> for your Webservice. So we need to add one more param in our request. It is <code>request.getParams().setParameter(CoreProtocolPNames.USE_EXPECT_CONTINUE, Boolean.FALSE);</code> . I have updated above code with this. Now it works fine. </p> <p><strong>Response looks something like this.</strong> </p> <p><img src="https://i.stack.imgur.com/3kUEB.png" alt="Response looks something like this."> </p> <p>Hope this will help.</p> <p>Cheers<br> N_JOY</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload