I am attempting to add authentication to a HTTP POST call but it fails with 401 Unauthorized. I have been over the documentation that I have and looking at other examples in this forum and I see most people are using this in the context of a HTTP GET. I am wondering if this is not working for POST?

 

 

ClientConfig cc = new DefaultClientConfig();
cc.getProperties().put(ClientConfig.PROPERTY_FOLLOW_REDIRECTS, Boolean.TRUE);
cc.getClasses().add(JAXBContextResolver.class);
rsClient = Client.create(cc);
WebResource resource = rsClient.resource(getNotificationRequestsUri());
resource.addFilter(new HTTPBasicAuthFilter(userName, String.valueOf(password)));
ClientResponse response = resource.entity(request, MediaType.APPLICATION_JSON_TYPE)
                     .accept(MediaType.APPLICATION_JSON).post(ClientResponse.class, request);

 

Any tips or feedback would be greatly appreciated.

FacebookTwitterLinkedin
Pin It
Joomla Tutorials for Beginners