Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6946285
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T13:32:43+00:00 2026-05-27T13:32:43+00:00

In my code I am posting data to a webservice, but the response I

  • 0

In my code I am posting data to a webservice, but the response I am getting from the webservice is that the specified data is empty.It means that my request is being processed by the webservice, but it’s not able the to fetch the corresponding key value.

Code:

Button b1=(Button)findViewById(R.id.button1);
        b1.setOnClickListener(new OnClickListener()
        {

            public void onClick(View v) {
                String gaurav ="new_member="+"[{\"email\":\"sinhagaurav@gmail.com\",\"username\":\"gaurav001\",\"pwd\":\"gaurav001\"}]";  
                // TODO Auto-generated method stub
                HttpClient httpclient = new DefaultHttpClient();   
                HttpPost httppost = new HttpPost("url");  

try{ 
    String d="saurav@gmail.com";
                    JSONObject json = new JSONObject(); 

                    json.put("gaurav", gaurav); 
                   // json.put("api_token",settings.getString("api_token", "")); 
                    StringEntity se = new StringEntity(json.toString()); 
                    httppost.setEntity(se); 
                    httppost.setHeader("Accept", "application/json");
                    httppost.setHeader("Content-type", "application/json");
                   se.setContentEncoding(new BasicHeader(HTTP.CONTENT_TYPE, "application/json")); 


                    HttpResponse response = httpclient.execute(httppost);   
                    HttpEntity responseEntity =response.getEntity(); 

                    Log.e("USER", EntityUtils.toString(responseEntity).trim()); 
} catch (UnsupportedEncodingException e11) { 
                    // TODO Auto-generated catch block 
                    Log.e("USER", e11.getMessage()); 
                } catch (ClientProtocolException e11) { 
                    // TODO Auto-generated catch block 
                    Log.e("USER", e11.getMessage()); 
                } catch (IOException e11) { 
                    // TODO Auto-generated catch block 
                    Log.e("USER", e11.getMessage()); 
                } catch (JSONException e11) { 
                    // TODO Auto-generated catch block 
                    e11.printStackTrace(); 
                }   

            }

        }
                );

The response from the server is:

12-16 13:59:47.542: E/USER(1257): [{"errorcode":"012"}]

List of response from server:

012 You must enter your e-mail address
013 You must enter your username
014 The username you chose is already taken
015 Your e-mail address is invalid
016 The e-mail address you entered is already taken
017 You must enter a password   
025 Your username should have at least 4 characters
024 Username can only contain letters A-Z and numbers 0-9

I am getting a feeling that all is going fine, and that either either my String gaurav; literal is the problem. Her is the string I have to pass as per webservice specifications:

new_member=[{“email”:”sinhagaurav@gmail.com”,”username”:”gaurav001″,”pwd”:”gaurav001″}]

I have tried many times but am still getting errorcode:12.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-27T13:32:44+00:00Added an answer on May 27, 2026 at 1:32 pm

    What I am doing is something like,

    JSONObject jsonObject = new JSONObject();
    jsonObject.put("email", "abc@xyz.com");
    jsonObject.put("uname", "test");
    jsonObject.put("upwd", "test123");
    
    JSONArray jArrayParam = new JSONArray();
    jArrayParam.put(jsonObject);
    
    List<NameValuePair> nameValuePair = new ArrayList<NameValuePair>();
    nameValuePair.add(new BasicNameValuePair("bulkdata",jArrayParam.toString()));
    
    HttpClient httpclient = new DefaultHttpClient();
    HttpPost httppost = new HttpPost(url);
    httppost.addHeader("Content-Type", "application/x-www-form-urlencoded");
    httppost.setEntity(new UrlEncodedFormEntity(nameValuePairs, HTTP.UTF_8));
    
    // Execute HTTP Post Request
    HttpResponse response = httpclient.execute(httppost);
    

    Using bulkdata you can get these values at server side..

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

i m using this code for posting and getting the data from the server.
I use following code for posting data to default2.aspx page. but when I trace
I currently have code for posting data to a login page that works fine.
I'm pasting test data from a SQL results into my code. I'm using the
I am porting some Core Data code from iPhone to Mac OS X. Problem
I am POSTING some data from an IPhone application want want to be able
I'm having some trouble POSTing data from a client machine to our internal site
I have data being imported from a database and I would like to represent
I'm validating and posting form data via ajax with code below. The problem is,
I'm trying to POSTing some data (a JSON string) from a php script to

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.