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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T22:13:56+00:00 2026-06-12T22:13:56+00:00

I’ve an app where i am trying to send data to a webservice using

  • 0

I’ve an app where i am trying to send data to a webservice using a http post. The user data is a mixture of strings int and doubles. In the app all are represented as Strings as when i use AsyncTask to run the network call, (so that it’s not on the main thread), the params array is of type String.

The problem i have is that the server expects an int sometimes. eg compID is an int that the server expects. When using the http post, i use NameValuePair. This will only accept strings. How can i pass an int or a double to the http post?

In my activity.

String[] params = new String[]{tagCompany, tagId, tagPerson, OUT,
                                null, null,null, null, null, null}; 
                        AsyncPostData apd = new AsyncPostData();
                        apd.execute(params);





private class AsyncPostData extends AsyncTask<String, Void, Void> {

        ProgressDialog progressDialog;

        @Override
        protected void onPreExecute()
        {
            progressDialog= ProgressDialog.show(NfcscannerActivity.this, 
                    "Connecting to Server"," Posting data...", true);            
        };  


        @Override
        protected Void doInBackground(String... params) {

            nfcscannerapplication.loginWebservice.postData(params[0], params[1], params[2], params[3], params[4],
                    params[5], params[6], params[7], params[8], params[9]);
            return null;
        }

         @Override
            protected void onPostExecute(Void result)
            {
             super.onPostExecute(result);
                if(progressDialog != null)
                progressDialog.dismiss();

            }
    }//end of AsyncPostData 

.

My post method

public void postData( String compID, String tagID, String clientID, String carerID, 
            String phoneScanned, String phoneSent, String TXType, String phoneType, String latitude, String longitude) {
        // Create a new HttpClient and Post Header
        HttpClient httpclient = new DefaultHttpClient();
        HttpPost httppost = new HttpPost("http://cfweb.yourofficeanywhere.co.uk:88/roadrunner.asmx/PostTransaction");


        try {
            // Add your data
            List<NameValuePair> nameValuePairs = new ArrayList<NameValuePair>(2);
            nameValuePairs.add(new BasicNameValuePair("CompanyID", compID));
            nameValuePairs.add(new BasicNameValuePair("TagID", tagID));
            nameValuePairs.add(new BasicNameValuePair("ClientID", clientID));
            nameValuePairs.add(new BasicNameValuePair("CarerID", carerID));
            nameValuePairs.add(new BasicNameValuePair("PhoneScanned", "2010-10-16 16:30 000"));
            nameValuePairs.add(new BasicNameValuePair("PhoneSent", "2010-10-16 16:32 000"));
            nameValuePairs.add(new BasicNameValuePair("TXType", "2"));
            nameValuePairs.add(new BasicNameValuePair("PhoneType", "2"));
            nameValuePairs.add(new BasicNameValuePair("Latitude", latitude));
            nameValuePairs.add(new BasicNameValuePair("Longitude", longitude));

            httppost.setEntity(new UrlEncodedFormEntity(nameValuePairs));

            // Execute HTTP Post Request
            HttpResponse response = httpclient.execute(httppost);

            Log.e(TAG, "response of post = " + response.toString());



        } catch (ClientProtocolException e) {
            // TODO Auto-generated catch block
        } catch (IOException e) {
            // TODO Auto-generated catch block
        }
    } 

In my post method some of the values are set to null for now. What i would like to know is how to make compID an int in the NameValuePair. compID comes over from the activity as a String but the server expects an int.

  • 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-12T22:13:57+00:00Added an answer on June 12, 2026 at 10:13 pm

    You can do something like this:

    nameValuePairs.add(new BasicNameValuePair("TXType",Integer.toString (2)));
    

    TxType is the key and 2 is the value

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

Sidebar

Related Questions

Let's say I'm outputting a post title and in our database, it's Hello Y&#8217;all
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
We're building an app, our first using Rails 3, and we're having to build
I am using Paperclip to handle profile photo uploads in my app. They upload
I'm trying to create an if statement in PHP that prevents a single post
I have a .ini file as follows: [playlist] numberofentries=2 File1=http://87.230.82.17:80 Title1=(#1 - 365/1400) Example
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 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

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.