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

  • SEARCH
  • Home
  • 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 8884197
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T21:00:34+00:00 2026-06-14T21:00:34+00:00

Possible Duplicate: How to send a JSON object over Request with Android? As I

  • 0

Possible Duplicate:
How to send a JSON object over Request with Android?

As I am new to Android development, I struck up with a problem sending requests to a web service in the form of JSON. Googling, I found the following code for sending requests using parameters. Here is the Java class we are sending parameters in the form of:

Main.java

RestClient client = new RestClient(LOGIN_URL);
client.AddParam("Email", _username);
client.AddParam("Passwd", _password);

try {
  client.Execute(RequestMethod.POST);
} catch (Exception e) {
  e.printStackTrace();
}
String response = client.getResponse();

But here I want to send parameters in the form of JSON, like for example I want to send parameters in this form:

{
  "login":{
    "Email":_username,
    "Passwd":_password,
  }
}

So, can anyone help me? How can I send parameters in the form of JSON?

  • 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-06-14T21:00:35+00:00Added an answer on June 14, 2026 at 9:00 pm

    The example you are posting uses a ‘library’ put together by someone as a wrapper around Apache’s HttpClient class. It’s not a particularly good one. But you don’t need to use that wrapper at all, the HttpClient itself is dead simple to utilize. Here’s a code sample you can build on:

    final String uri = "http://www.example.com";
    final String body = String.format("{\"login\": {\"Email\": \"%s\", \"Passwd\": \"%s\"}", "me@email.com", "password");
    
    final HttpClient client = new DefaultHttpClient();
    final HttpPost postMethod = new HttpPost(uri);
    postMethod.setEntity(new StringEntity(body, "utf-8"));
    
    try {
        final HttpResponse response = client.execute(postMethod);
        final String responseData = EntityUtils.toString(response.getEntity(), "utf-8");
    } catch(final Exception e) {
        // handle exception here
    }
    

    Note that you would most likely be using a JSON library to serialize a POJO and create the request JSON.

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

Sidebar

Related Questions

Possible Duplicate: Sending JSON jQuery Ajax to PHP and back i need to send
Possible Duplicate: How to send an object from one Android Activity to another using
Possible Duplicate: Sending HTML email from PHP I need to send an html mail
Possible Duplicate: Sending email in .NET through Gmail I am trying to send a
Possible Duplicate: How to programmatically send SMS on the iPhone? i am new to
Possible Duplicate: How to send HTTP request and retrieve response in PHP (with fine-tuning
Possible Duplicate: how to parse json in javascript My server is configured to send
Possible Duplicate: JSON order mixed up By Microsoft convension i need send Json as
Possible Duplicate: SMS from web application Sample code to send Mail via php //
Possible Duplicate: SMS from web application Sample code to send Mail via php //

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.