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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T16:40:50+00:00 2026-06-07T16:40:50+00:00

Been trying to figure out what’s wrong with this one for a while. I’m

  • 0

Been trying to figure out what’s wrong with this one for a while. I’m making a post request with HttpClient.execute with a json body to my server api. Works fine under normal wifi and most 3g, but specifically on phones with AT&T dataplans and it’s on 3g, I’m getting back a HttpResponseException when I try to execute the request, status code 422. Did some research on 422 and it says it’s due to:

“422 Unprocessable Entity (WebDAV) (RFC 4918 ), The request was well-formed but was unable to be followed due to semantic errors.”

So I’m guessing something is going wrong in how the request goes out, but I’m doing the same thing in forming the request, whether I’m on wifi or 3g. Any ideas on what might be causing this error?

Edit:
Looked like my server was catching the post with the forgery protection. Turned it off and the error stopped, but the api didn’t go through. Dug a little deeper and printed out what was actually getting received by the server, did a comparison between wifi on and off, noticed two differences. First, the body was empty on 3g, seems like it somehow got blocked from being sent. Second, the header changed the content type being sent:

wifi: “HTTP_CONTENT_TYPE”=>”application/json”
att 3g: “HTTP_CONTENT_TYPE”=>”text/plain; charset=ISO-8859-1,application/json”

I’m expecting “application/json” given that I’m setting up my connection like this:

StringEntity se = new StringEntity(json.toString());
se.setContentEncoding(new BasicHeader(HTTP.CONTENT_TYPE, "application/json"));

Any ideas why things are changing when I move over to 3g?

Update: Ran a tcpdump and looks like what I’m sending from the android is exactly the same between wifi and 3g, so it seems that it’s the provider that’s making a change to my data. Any other proposed strategies other than HTTPS?

  • 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-07T16:40:52+00:00Added an answer on June 7, 2026 at 4:40 pm

    Solved!

    Old Code:

        mPost = new HttpPost(ur);
        StringEntity se = new StringEntity(json.toString());
        se.setContentEncoding(new BasicHeader(HTTP.CONTENT_TYPE, "application/json"));
        mPost.setEntity(se);
    

    New Code:

        mPost = new HttpPost(ur);
        ByteArrayEntity baEntity = new ByteArrayEntity(json.toString().getBytes("UTF8"));
        baEntity.setContentEncoding(new BasicHeader(HTTP.CONTENT_TYPE, "application/json"));
        mPost.setEntity(baEntity);
    

    Pretty much looks like using ByteArrayEntity instead of StringEntity as my post’s body makes it work on 3g. Not sure exactly why this is given the tcpdump between wifi and 3g looked exactly the same while using StringEntity, but it seems to have fixed the problem so I’m not complaining.

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

Sidebar

Related Questions

I have been trying to figure out why I am getting this problem and
So I've been trying to figure out what is wrong with my if-condition, but
I've been trying to figure out how to do this all afternoon, but can't
I've been trying to figure out how to do this, and was thinking it
I've been trying to figure out how to write this regular expression. It is
I been trying to figure out how this blasted regex for two hours!!! It's
I've been trying to figure out a little mystery now for a while, but
I've been trying to figure out why this Java program I am trying to
I've been trying to figure out if this is possible the way I've done
I've been trying to figure out how to work this jQuery Form plugin 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.