Hey Emmanuel, If you're using Java, I'd highly suggest using solrj, it'll do the work that you need it to do:
SolrRequest req ;//create a new request object req.setBasicAuthCredentials(userName, password); solrClient.request(req); If that doesn't work for you for some reason, you need to base64 encode the username:password combo for basic http auth: String auth = Base64.getEncoder().encodeToString("solr:SolrRocks".getBytes()); headers.add("Authorization", "Basic " + auth ); Also, I'm not sure if java.net.HttpClient has basic auth built in, but apache HttpClient sure does... Kyle On Thu, 26 Mar 2020 at 15:27, Altamirano, Emmanuel < emmanuel.altamir...@transunion.com> wrote: > Hello everyone, > > > > We recently enable Solr Basic Authentication in our Dev environment and we > are testing Solr security. We followed the instructions provided in the > Apache Solr website and it is working using curl command. > > > > If you could provide us any advice of how do we need to send the > credentials in the HTTP headers in a Java program? It is very appreciate it. > > > > HttpHeaders headers = *new* HttpHeaders(); > > headers.setAccept(Arrays.*asList*(MediaType.*APPLICATION_JSON*)); > > headers.setContentType(MediaType.*APPLICATION_JSON*); > > headers.add("Authorization", "Basic " + "solr:SolrRocks"); > > > > Thanks, > > > > *Emmanuel Altamirano,* > > Consultant - Global Technology > > International Operations > > > > *Telephone:* 312-985-3149 > > *Mobile:* 312-860-3774 > > > > *[image: cid:image001.png@01D02A68.19FA64F0]* > > > > 555 W. Adams 5th Floor > > Chicago, IL 60661 > > *transunion.com <http://www.transunion.com/>* > > > > This email including, without limitation, the attachments, if any, > accompanying this email, may contain information which is confidential or > privileged and exempt from disclosure under applicable law. The information > is for the use of the intended recipient. If you are not the intended > recipient, be aware that any disclosure, copying, distribution, review or > use of the contents of this email, and/or its attachments, is without > authorization and is prohibited. If you have received this email in error, > please notify us by reply email immediately and destroy all copies of this > email and its attachments. > > >