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

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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T06:10:23+00:00 2026-05-23T06:10:23+00:00

Thanks in advance… i m using this code for set http header in http

  • 0

Thanks in advance…

i m using this code for set http header in http request for authenticate url..

but i think some what is mising thats why i could not get response…

response still comes like “authoriazation required”…

httpParameters = new BasicHttpParams();
String auth = android.util.Base64.encodeToString(
    ("florin999@zitec.ro" + ":" + "test2323" + ":" + "zitec"
    + ":" + "7716099f468cc71670b68cf4b3ba545c5760baa7")
    .getBytes("UTF-8"), android.util.Base64.NO_WRAP);

HttpConnectionParams.setSoTimeout(httpParameters, 0);
client = new DefaultHttpClient(httpParameters);
String getURL = "URL here";
get = new HttpGet(getURL);
get.addHeader("Authorization", "Basic "+ auth);
// get.addHeader("X-ZFWS-Accept", "text/json");

HttpResponse responseGet = client.execute(get);
HttpEntity resEntityGet = responseGet.getEntity();
if (resEntityGet != null) {
    //do something with the response
    //Toast.makeText(Login.this.getApplicationContext(),EntityUtils.toString(resEntityGet), Toast.LENGTH_SHORT).show();
    String s = EntityUtils.toString(resEntityGet);
    tv1.setText(s);
}
}catch(Exception e){
}

plssss help me as soon as possible

  • 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-23T06:10:24+00:00Added an answer on May 23, 2026 at 6:10 am

    Yor code is fine. you have the http client setup right and the header added right. but. your basic authentication is wrong. the header key (Authentication) is right but the value should be Basic + Base64.encode(username+”:”+pass)

    also the alternative to that is the folowing code:

     httpclient.getCredentialsProvider().setCredentials(
                    new AuthScope(targetHost.getHostName(), targetHost.getPort()),
                    new UsernamePasswordCredentials("username", "password"));
    

    The target Hostname is probably null and the port -1.

    but this one you wont be able to use if you are using url connection so a header is also acceptable.

    EDIT:

    HERE IS YOUR ISSUE:

    String auth = android.util.Base64.encodeToString(
        ("florin999@zitec.ro" + ":" + "test2323" + ":" + "zitec"
        + ":" + "7716099f468cc71670b68cf4b3ba545c5760baa7")
        .getBytes("UTF-8"), android.util.Base64.NO_WRAP);
    

    What are all theese concatenations??

    Basic authentication means adding a base64 encoded Authorization header which consisnt of the word "Basic " + Base64.encodeToString("yourUsername"+":"+"yourPassword)

    The alternative is adding the method i pasted at the top about the credentials provider the same way

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

Sidebar

Related Questions

Thanks in advance. Getting this warning when using below code: Warning: file_get_contents(test.php) [function.file-get-contents]: failed
thanks in advance for your help. I'm using this piece of code to replace
Thanks in advance. I know crop an image using CGRect value and masking .But
Thanks in advance. I fetch image url in array. myarray = { http://www.abc.com/uploads/sarab.jpg, ....
Thanks in Advance for reading and answer this question. I got button in asp
First of all thanks in advance, this has been very frustrating and I'm hoping
I am using c# .net. Thanks in advance for any help. I have searched
This is a total newbie question, so thanks in advance. I'm trying to get
Thanks in advance for taking the time to read this. Apologies that it is
Thanks in advance to anyone who takes time to respond. I truly appreciate this

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.