user3013257
user3013257

Reputation:

Different ways to post json values to Server

i have created a login WCF service that is tested successfully using fiddler and postman tool..!

json post test

If the login process is success then WCF will give the json message as above screenshot. But when i posted username and password from android it gives the result as [{"message":"not created","success":-1}].i cant figure it out where the bug actually is.!! i am providing the corresponding android code and logcat below.please help me If the login process is success then WCF will give the json message as above screenshot.

But when i posted username and password from android it gives the result as [{"message":"not created","success":-1}].i cant figure it out where the bug actually is.!!

i am providing the corresponding android code and logcat below.please help me

If the login process is success then WCF will give the json message as above screenshot.

But when i posted username and password from android it gives the result as [{"message":"not created","success":-1}].i cant figure it out where the bug actually is.!!

i am providing the corresponding android code and logcat below.please help me

Logcat

below is webservice code in android

enter image description here

Upvotes: 1

Views: 314

Answers (1)

duggu
duggu

Reputation: 38439

try below code:-

HttpClient client = new DefaultHttpClient();
            HttpConnectionParams.setConnectionTimeout(client.getParams(), 60000);
            HttpResponse response;

    try
    {

            JSONObject j = new JSONObject();
            j.put("UserName", "hiqmaali");
            j.put("Password", "qwerty");
        Messages.onLowmemory();
        HttpPost post = new HttpPost(HOST_URL);

        StringEntity stringEntity = new StringEntity(j.toString(), "UTF-8");
        post.setEntity(stringEntity);

        response = client.execute(post);

In your case send json to server so u have to try above way.

Upvotes: 2

Related Questions