Pass Header basic Auth using Jersey Client

I am fairly new to Rest , I am stuck

I need to pass a header like :-
name ="Authorization"
value = "Basic xxxxxxxxxxxx"

My code is:
Client c = ClientBuilder.newBuilder().register(MultiPartFeature.class).build();
 Response info= c.target(<URL>).property("Authorization", "Basic xxxxxxxxxxxx").request().get();

The response I got is:-
InboundJaxrsResponse{ClientResponse{method=GET, uri=<my URL> status=401, reason=Unauthorized}}

what is the correct way to pass a header ?
NishantKashyapAsked:
Who is Participating?

[Webinar] Streamline your web hosting managementRegister Today

x
 
NishantKashyapConnect With a Mentor Author Commented:
I updated my Jersey client to 2.X and the issue was resolved.
0
 
käµfm³d 👽Commented:
Did you base-64-encode the "xxxxxxxxxxxxxxx" part?
0
 
NishantKashyapAuthor Commented:
There was bug with the earlier jersey client which I was using , When I upgraded to 2.4 version , it worked fine.
0
All Courses

From novice to tech pro — start learning today.