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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T23:47:31+00:00 2026-05-16T23:47:31+00:00

I’ve got an android application that I’m attempting to use to pass some data

  • 0

I’ve got an android application that I’m attempting to use to pass some data to a webservice using HTTPGet. If I just construct the string using the JSONArray.toString() method, I end up with a URL that looks something like the following:

http://xxx.xx.xxx.xx/api?method=upload&args[deviceID]=123456789&args[data]=["{element1=93295352, element2=235235, element3=3523523}","{element1=93295352, element2=235235, element3=3523523}"]

This doesn’t work because of the spaces and quotation marks in the URL. If I attampt to do something like the following:

JSONArray ja = new JSONArray();

// Add Data to JSONArray

String s = ja.toString();

// Add array to StringBuilder url

HTTPGet httpget = new HTTPGet(UrlEncoder.encode(url.toString()));

I get an error thrown because the entire URL gets encoded and ends up like this:

http%3A%2F%2Fxxx.xx.xxx.xx%2Fapi%3Fmethod%3Dupload%26args%5BdeviceID%5D%3D123456879%26args%5Bdata%5D%3D%5B%22%7Belement1%3D915156028000%2C+element2%3D1651651%2C+element3%3D489461%7D%22%2C%22

Obviously, this isn’t what I’m looking for, and there’s got to be a better solution than searching/replacing all the necessary characters in the JSONArray portion of that url, though I suppose doing it that way wouldn’t be a huge hassle since I’m only worried about quotation and space characters.

Note that manually pasting this into my browser returned the results I expect:

http://xxx.xx.xxx.xx/api?method=upload&args[deviceID]=123456789&args[data]=[%22{element1=915156028000,%20element2=0.0,%20element3=2.297444}%22,%22{element1=915156055000,%20element2=0.0,%20element3=2.2974419999999998}%22]
  • 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-16T23:47:31+00:00Added an answer on May 16, 2026 at 11:47 pm

    You need to URL encode just the query argument value; for example

    JSONArray ja = new JSONArray();
    
    // Add Data to JSONArray
    
    String s = UrlEncoder.encode(ja.toString());
    
    // Add string to StringBuilder url
    
    HTTPGet httpget = new HTTPGet(url.toString());
    

    The other thing that you need to be aware of is that there are practical limits on the length of a URL. These limits vary from one implementation to another (browser, server, proxy, HTTP client library, etc). In some cases, it is as low as 2k bytes, IIRC.

    FOLLOW UP

    If I want to do the same thing using POST instead, do I end up having to encode the data in the same manner?

    It depends.

    • If you sent the arguments as URL query arguments with a POST, the same encoding rules and limits would apply. For the record, the URL encoding rules are part of the URL and URI specs.
    • If instead you sent the arguments as POST data using the “application/x-www-form-urlencoded” content type, the encoding rules are a bit different; see the HTML spec. (The main difference is that this encoding encodes spaces as + characters.)
    • You could also encode the POST data in some other way, provided that the HTTP client and server both understood the encoding and content type.

    Of course, one of the advantages of using POST data is that there is typically no limit on the size of the arguments you can send.

    • 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
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I've got a string that has curly quotes in it. I'd like to replace
I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this
I want to construct a data frame in an Rcpp function, but when I
link Im having trouble converting the html entites into html characters, (&# 8217;) i
For some reason, after submitting a string like this Jack’s Spindle from a text
I am trying to understand how to use SyndicationItem to display feed which is
I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
I am reading a book about Javascript and jQuery and using one of the

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.