http Client Authentication

http Client Authentication

hi friends,

i am trying a java API using HTTPCLient post method.  in which i am getting output having some authentication problem. can any one please help me to solve this problem.

please , please help me.. waiting for reply.

Thanks in advance.

This is what the PROGRAM

import org.apache.commons.httpclient.*;
import org.apache.commons.httpclient.methods.*;

public class sms {

public static void main( String[] args ) throws Exception  {

 String qURL="http://9.184.65.219:10038";    
    String UserId="adm";    
    String Password="adm";
    String postTitle="Pls11";

    byte entry[] = ("<?xml version=\"1.0\" encoding=\"UTF-8\"?><entry xmlns=\"http://www.w3.org/2005/Atom\"> <title type=\"text\"> "+postTitle+" </title></entry>").getBytes();

String placeurl = qURL+"/asd/myquic"+"/feed";

 try {
    System.out.println("\n Place Collection URL = "+ placeurl);

HttpClient client = new HttpClient();
PostMethod method = new PostMethod( placeurl );

 // Configure the form parameters

  method.addParameter( "CONTENT-TYPE", "application/atom+xml" );
  method.addParameter( "CONTENT-LENGTH", new Integer(entry.length).toString() );
  method.addParameter( "Host", "localhost");
  method.addParameter( "User-Agent", "Thingio/1.0" );
  method.addParameter( "Keep-Alive", "header");
  method.addParameter( "Authorization", "Basic " + (new  sun.misc.BASE64Encoder().encode((UserId+":"+Password).getBytes())));

System.out.write(entry);

 // Execute the POST method
int statusCode = client.executeMethod( method );

System.out.println("\n Response status code: " + statusCode);

// Display response
System.out.println("\n Response body: ");
System.out.println(method.getResponseBodyAsString());

 }

 catch( Exception e ) {
    System.err.println ( "\n Exception...\n" + e ) ;
    e.printStackTrace();
   }
 }

}

output
Place Collection URL = http://9.184.65.219:10038/asd/myquic/feed
<?xml version="1.0" encoding="UTF-8"?><entry xmlns="http://www.w3.org/2005/Atom">
Pls11 Jan 10, 2011 3:17:19 PM org.apache.commons.httpclient.auth.AuthChallengeProcessor selectAuthScheme
INFO: basic authentication scheme selected
Jan 10, 2011 3:17:19 PM org.apache.commons.httpclient.HttpMethodDirector processWWWAuthChallenge
INFO: No credentials available for BASIC 'Atom'@9.184.65.219:10038

Response status code: 401

Response body: 
Thanks and regards,
Milind.
View Answers









Related Tutorials/Questions & Answers:
http Client Authentication
http Client Authentication  hi friends, i am trying a java API... authentication problem. can any one please help me to solve this problem. please... ) throws Exception { String qURL="http://9.184.65.219:10038"; String
ModuleNotFoundError: No module named 'django-http-authentication'
ModuleNotFoundError: No module named 'django-http-authentication'  Hi...: No module named 'django-http-authentication' How to remove the ModuleNotFoundError: No module named 'django-http-authentication' error? Thanks
Advertisements
ModuleNotFoundError: No module named 'django-http-authentication'
ModuleNotFoundError: No module named 'django-http-authentication'  Hi...: No module named 'django-http-authentication' How to remove the ModuleNotFoundError: No module named 'django-http-authentication' error? Thanks
ModuleNotFoundError: No module named 'jwt-client-authentication'
ModuleNotFoundError: No module named 'jwt-client-authentication'  Hi...: No module named 'jwt-client-authentication' How to remove the ModuleNotFoundError: No module named 'jwt-client-authentication' error? Thanks  
Spring Security HTTP basic authentication
Spring Security HTTP basic authentication In this section, you will learn about the HTTP basic authentication in Spring Security. You can configure HTTP... Security HTTP basic authentication configuration--> <http> <intercept
Version of com.cognitect>http-client dependency
List of Version of com.cognitect>http-client dependency
Version of com.jslsolucoes>http-client dependency
List of Version of com.jslsolucoes>http-client dependency
Version of com.metamx>http-client dependency
List of Version of com.metamx>http-client dependency
Version of com.rabbitmq>http-client dependency
List of Version of com.rabbitmq>http-client dependency
ModuleNotFoundError: No module named 'http_client'
ModuleNotFoundError: No module named 'http_client'  Hi, My Python... 'http_client' How to remove the ModuleNotFoundError: No module named 'http_client' error? Thanks   Hi, In your python environment
Maven Repository/Dependency: com.turbomanage.basic-http-client | http-client
Maven Repository/Dependency of Group ID com.turbomanage.basic-http-client and Artifact ID http-client. Latest version of com.turbomanage.basic-http-client:http-client dependencies. # Version Release Date
apache http client maven dependency
apache http client maven dependency  Hi, I want to use Apache Http... the dependency which I should add to my pom.xml file. What is apache http client maven dependency code? Thanks   Hi, Apache Http Client is used
Maven Repository/Dependency: com.turbomanage.basic-http-client | http-client-android
Maven Repository/Dependency of Group ID com.turbomanage.basic-http-client and Artifact ID http-client-android. Latest version of com.turbomanage.basic-http-client:http-client-android dependencies. # Version
Maven Repository/Dependency: org.jvnet.robust-http-client | robust-http-client
Maven Repository/Dependency of Group ID org.jvnet.robust-http-client and Artifact ID robust-http-client. Latest version of org.jvnet.robust-http-client:robust-http-client dependencies. # Version Release Date
Maven Repository/Dependency: clojure-http-client | clojure-http-client
Maven Repository/Dependency of Group ID clojure-http-client and Artifact ID clojure-http-client. Latest version of clojure-http-client:clojure-http-client dependencies. # Version Release Date
Maven Repository/Dependency: com.turbomanage.basic-http-client | http-client-java
Maven Repository/Dependency of Group ID com.turbomanage.basic-http-client and Artifact ID http-client-java. Latest version of com.turbomanage.basic-http-client:http-client-java dependencies. # Version Release
Version of com.agapsys>simple-http-client dependency
List of Version of com.agapsys>simple-http-client dependency
Version of com.dslplatform>dsl-client-http dependency
List of Version of com.dslplatform>dsl-client-http dependency
Version of com.gooddata>gooddata-http-client dependency
List of Version of com.gooddata>gooddata-http-client dependency
Version of com.nycjv321>simple-http-client dependency
List of Version of com.nycjv321>simple-http-client dependency
Version of com.sendgrid>java-http-client dependency
List of Version of com.sendgrid>java-http-client dependency
ModuleNotFoundError: No module named 'bosch-thermostat-http-client'
ModuleNotFoundError: No module named 'bosch-thermostat-http-client'  ...: No module named 'bosch-thermostat-http-client' How to remove the ModuleNotFoundError: No module named 'bosch-thermostat-http-client' error
ModuleNotFoundError: No module named 'cdumay-http-client'
ModuleNotFoundError: No module named 'cdumay-http-client'  Hi, My... named 'cdumay-http-client' How to remove the ModuleNotFoundError: No module named 'cdumay-http-client' error? Thanks   Hi, In your
ModuleNotFoundError: No module named 'cloudwright-base-http-client'
ModuleNotFoundError: No module named 'cloudwright-base-http-client'  ...: No module named 'cloudwright-base-http-client' How to remove the ModuleNotFoundError: No module named 'cloudwright-base-http-client' error
ModuleNotFoundError: No module named 'prometheus-http-client'
ModuleNotFoundError: No module named 'prometheus-http-client'  Hi...: No module named 'prometheus-http-client' How to remove the ModuleNotFoundError: No module named 'prometheus-http-client' error? Thanks   Hi
ModuleNotFoundError: No module named 'python-http-client'
ModuleNotFoundError: No module named 'python-http-client'  Hi, My... named 'python-http-client' How to remove the ModuleNotFoundError: No module named 'python-http-client' error? Thanks   Hi, In your
ModuleNotFoundError: No module named 'resource-api-http-client'
ModuleNotFoundError: No module named 'resource-api-http-client'  Hi...: No module named 'resource-api-http-client' How to remove the ModuleNotFoundError: No module named 'resource-api-http-client' error? Thanks  
ModuleNotFoundError: No module named 'tx-sendgrid-http-client'
ModuleNotFoundError: No module named 'tx-sendgrid-http-client'  Hi...: No module named 'tx-sendgrid-http-client' How to remove the ModuleNotFoundError: No module named 'tx-sendgrid-http-client' error? Thanks   
ModuleNotFoundError: No module named 'tx-sendgrid-http-client'
ModuleNotFoundError: No module named 'tx-sendgrid-http-client'  Hi...: No module named 'tx-sendgrid-http-client' How to remove the ModuleNotFoundError: No module named 'tx-sendgrid-http-client' error? Thanks   
ModuleNotFoundError: No module named 'bosch-thermostat-http-client'
ModuleNotFoundError: No module named 'bosch-thermostat-http-client'  ...: No module named 'bosch-thermostat-http-client' How to remove the ModuleNotFoundError: No module named 'bosch-thermostat-http-client' error
ModuleNotFoundError: No module named 'bosh-thermostat-http-client'
ModuleNotFoundError: No module named 'bosh-thermostat-http-client'  ...: No module named 'bosh-thermostat-http-client' How to remove the ModuleNotFoundError: No module named 'bosh-thermostat-http-client' error? Thanks
ModuleNotFoundError: No module named 'cdumay-http-client'
ModuleNotFoundError: No module named 'cdumay-http-client'  Hi, My... named 'cdumay-http-client' How to remove the ModuleNotFoundError: No module named 'cdumay-http-client' error? Thanks   Hi, In your
ModuleNotFoundError: No module named 'cloudwright-generic-http-client'
ModuleNotFoundError: No module named 'cloudwright-generic-http-client' ...: ModuleNotFoundError: No module named 'cloudwright-generic-http-client' How to remove the ModuleNotFoundError: No module named 'cloudwright-generic-http-client' error
ModuleNotFoundError: No module named 'cloudwright-http-client'
ModuleNotFoundError: No module named 'cloudwright-http-client'  Hi...: No module named 'cloudwright-http-client' How to remove the ModuleNotFoundError: No module named 'cloudwright-http-client' error? Thanks   
ModuleNotFoundError: No module named 'cloudwright-http-client'
ModuleNotFoundError: No module named 'cloudwright-http-client'  Hi...: No module named 'cloudwright-http-client' How to remove the ModuleNotFoundError: No module named 'cloudwright-http-client' error? Thanks   
ModuleNotFoundError: No module named 'opentsdb-http-client'
ModuleNotFoundError: No module named 'opentsdb-http-client'  Hi...: No module named 'opentsdb-http-client' How to remove the ModuleNotFoundError: No module named 'opentsdb-http-client' error? Thanks   Hi
ModuleNotFoundError: No module named 'python-http-client'
ModuleNotFoundError: No module named 'python-http-client'  Hi, My... named 'python-http-client' How to remove the ModuleNotFoundError: No module named 'python-http-client' error? Thanks   Hi, In your
ModuleNotFoundError: No module named 'cloudwright-base-http-client'
ModuleNotFoundError: No module named 'cloudwright-base-http-client'  ...: No module named 'cloudwright-base-http-client' How to remove the ModuleNotFoundError: No module named 'cloudwright-base-http-client' error
ModuleNotFoundError: No module named 'easydb-http-client'
ModuleNotFoundError: No module named 'easydb-http-client'  Hi, My... named 'easydb-http-client' How to remove the ModuleNotFoundError: No module named 'easydb-http-client' error? Thanks   Hi, In your
ModuleNotFoundError: No module named 'flask-http-client'
ModuleNotFoundError: No module named 'flask-http-client'  Hi, My... named 'flask-http-client' How to remove the ModuleNotFoundError: No module named 'flask-http-client' error? Thanks   Hi, In your
ModuleNotFoundError: No module named 'http-test-client'
ModuleNotFoundError: No module named 'http-test-client'  Hi, My... named 'http-test-client' How to remove the ModuleNotFoundError: No module named 'http-test-client' error? Thanks   Hi, In your
Basic authentication
the client's built in authentication mechanism. In java programming language... Basic authentication       Basic authentication is the process through which a web server authenticates
Maven Dependency http-client >> 0.1.71
You should include the dependency code given in this page to add Maven Dependency of com.cognitect >> http-client version0.1.71 in your project
Maven Dependency http-client >> 0.1.73
You should include the dependency code given in this page to add Maven Dependency of com.cognitect >> http-client version0.1.73 in your project
Maven Dependency http-client >> 1.0.0
You should include the dependency code given in this page to add Maven Dependency of com.jslsolucoes >> http-client version1.0.0 in your project
Maven Dependency http-client >> 1.1.0.RELEASE
You should include the dependency code given in this page to add Maven Dependency of com.rabbitmq >> http-client version1.1.0.RELEASE in your project
Maven Dependency http-client >> 1.1.1.RELEASE
You should include the dependency code given in this page to add Maven Dependency of com.rabbitmq >> http-client version1.1.1.RELEASE in your project
Maven Dependency http-client >> 0.1.62
You should include the dependency code given in this page to add Maven Dependency of com.cognitect >> http-client version0.1.62 in your project
Maven Dependency http-client >> 1.0.0
You should include the dependency code given in this page to add Maven Dependency of com.metamx >> http-client version1.0.0 in your project
Maven Dependency http-client >> 1.0.0.RELEASE
You should include the dependency code given in this page to add Maven Dependency of com.rabbitmq >> http-client version1.0.0.RELEASE in your project

Ads