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 7893153
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T07:03:25+00:00 2026-06-03T07:03:25+00:00

I’m trying to save some information from a user that is saved on the

  • 0

I’m trying to save some information from a user that is saved on the android phone to a WCF service. I’m getting a 400 error from the phone and when I try to send the same request to the server using fiddler (when testing on my localhost) my visual studio’s pops up a null pointer in my save method. I’m following this example to the tee and its just not working: Tutorial

Here some of my code:
Here’s my user object in the WCF service:

[DataContract]
public class User
{
    [DataMember(Name= "userid")]
    public int UserId { get; set; }
    [DataMember(Name = "username")]
    public string username { get; set; }
    [DataMember(Name = "password")]
    public string password { get; set; }
    [DataMember(Name = "information")]
    public Byte[] information { get; set; }
}

Operation contract in my IService

    [OperationContract]
    [WebInvoke(Method = "POST",
        BodyStyle = WebMessageBodyStyle.Bare, 
        ResponseFormat = WebMessageFormat.Xml, 
        RequestFormat= WebMessageFormat.Json,
        UriTemplate = "saveUser")]
    Boolean saveUser(User user);

^ this method is throwing a null pointer because the user is null. I have tried changing the WebMessageBodyStyle to WrappedRequest but that doesn’t help.

Heres the android code for sending the POST Request:

JSONStringer user = new JSONStringer()
                .object()
                    .key("user").object()
                    .key("userid").value("1").key("username").value(appState.getCurrentUser().username)
                        .key("password").value(appState.getCurrentUser().password)
                        .key("information").value(str.toString())
                    .endObject()
                .endObject();
            StringEntity entity = new StringEntity(user.toString());
            HttpPost request = new HttpPost(new URI(url));
            request.setHeader(HTTP.CONTENT_TYPE, "application/json");
            request.setHeader("Accept", "application/json");

            request.setEntity(entity);
HttpResponse response = httpClient.execute(request);

^ the response is giving me a 400 error from the server.

Here is the fiddler sending the json to the localhost:
Here’s the picture
I added the content-length but in the picture it says 0. it really is 86.
Any help would be a appreciated.

  • 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-03T07:03:26+00:00Added an answer on June 3, 2026 at 7:03 am

    If you look at how I was sending the byte[] it was really a string and when the JSON Object got to the service the service couldn’t figure out where to put this information string. I feel like a complete noob after finding this.

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

Sidebar

Related Questions

I have just tried to save a simple *.rtf file with some websites and
For some reason, after submitting a string like this Jack’s Spindle from a text
I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this
I'm trying to decode HTML entries from here NYTimes.com and I cannot figure out
I'm trying to create an if statement in PHP that prevents a single post
I am trying to understand how to use SyndicationItem to display feed which is
Basically, what I'm trying to create is a page of div tags, each has
link Im having trouble converting the html entites into html characters, (&# 8217;) i
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function

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.