0

When I try to add the user for the Solr Basic Authentication using the following method in curl

curl --user user:password http://localhost:8983/solr/admin/authentication -H 'Content-type:application/json' -d '{
  "set-user": {"tom" : "TomIsCool" ,
           "harry":"HarrysSecret"}}'

I get the following error:

{
  "responseHeader":{
"status":400,
"QTime":0},
 "error":{
"metadata":[
  "error-class","org.apache.solr.common.SolrException",
  "root-error-class","org.apache.solr.common.SolrException"],
"msg":"No contentStream",
"code":400}}
curl: (3) [globbing] unmatched brace in column 1
枩]?V7`-{炘9叡 t肤 ,? E'qyT咐黣]儎;衷 鈛^W褹?curl: (3) [globbing] unmatched cl
ose brace/bracket in column 13

What does this error means and how should we resolve it? I'm using SolrCloud on Solr 6.4.2.

Regards,
Edwin

Edwin Yeo
  • 165
  • 1
  • 2
  • 14

1 Answers1

1

If you're using curl under Windows, this is a known issue with cmd.exe's escaping of single quotes. Use double quotes around your JSON string (or use cygwin, powershell, etc.)

curl --user user:password http://localhost:8983/solr/admin/authentication -H 
    "Content-type:application/json" -d "{
       \"set-user\": {\"tom\" : \"TomIsCool\" ,
       \"harry\":\"HarrysSecret\"}}"

The "globbing" message from curl is the hint that curl is doing something else than what you intended, and that the actual body of the request isn't getting to Solr (which is complaining about no message body being present).

You could also get around this by using stream.body in the URL and making the request from your browser.

MatsLindh
  • 49,529
  • 4
  • 53
  • 84
  • Thanks @MatsLindh for your answer. I managed to get it to work in curl. However, I could not get it to work using the stream.body, and I can't find any example. Do you have any example on this? – Edwin Yeo Apr 13 '17 at 12:40
  • https://cwiki.apache.org/confluence/display/solr/Content+Streams - Maybe it doesn't work with JSON messages. Not sure. – MatsLindh Apr 13 '17 at 13:04