Go Premium for a chance to win a PS4. Enter to Win

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 562
  • Last Modified:

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 ?
0
NishantKashyap
Asked:
NishantKashyap
  • 2
1 Solution
 
käµfm³d 👽Commented:
Did you base-64-encode the "xxxxxxxxxxxxxxx" part?
0
 
NishantKashyapAuthor Commented:
I updated my Jersey client to 2.X and the issue was resolved.
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

Featured Post

Vote for the Most Valuable Expert

It’s time to recognize experts that go above and beyond with helpful solutions and engagement on site. Choose from the top experts in the Hall of Fame or on the right rail of your favorite topic page. Look for the blue “Nominate” button on their profile to vote.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now