Reputation: 243
I am beginer to work with WebServices
Method Type: POST
Request Parameters : {loginid:'[email protected]', password:'yyyyy'}
I was tried like below:
JSONObject jObj = new JSONObject();
try {
jObj.put("loginid", email.getText());
jObj.put("password", password.getText());
}
how can i write the JSON code for it.
Upvotes: 2
Views: 43
Reputation: 6108
JSONObject jObj = new JSONObject();
try {
jObj.put("loginid", email.getText());
jObj.put("password", password.getText());
}
HttpClient client = new DefaultHttpClient();
HttpPost post = new HttpPost("www.yoursite.com/page");
StringEntity se = new StringEntity(jObj.toString());
se.setContentType(new BasicHeader(HTTP.CONTENT_TYPE, "application/json"));
post.setHeader("Accept", "application/json");
post.setHeader("Content-type", "application/json");
post.setEntity(se);
client.execute(post);
Upvotes: 2