Error loading sample data

I am trying to follow the tutorial available here: https://www.elastic.co/guide/en/kibana/current/tutorial-load-dataset.html

Where I am trying to run this:

curl -XPUT http://localhost:9200/shakespeare -d '
{
 "mappings" : {
  "_default_" : {
   "properties" : {
    "speaker" : {"type": "string", "index" : "not_analyzed" },
    "play_name" : {"type": "string", "index" : "not_analyzed" },
    "line_id" : { "type" : "integer" },
    "speech_number" : { "type" : "integer" }
   }
  }
 }
}
';

I am getting an error regarding authentication:

{"error":{"root_cause":[{"type":"security_exception","reason":"missing authentication token for REST request [/shakespeare]","header":{"WWW-Authenticate":"Basic realm="security" charset="UTF-8""}}],"type":"security_exception","reason":"missing authentication token for REST request [/shakespeare]","header":{"WWW-Authenticate":"Basic realm="security" charset="UTF-8""}},"status":401}

Any solutions?

Thank you!

Thankfully I found the solution myself after doing some testing. I will post the solution incase anyone has the same issue:

I have X-pack installed and I believe that might have conflicted with the authentication portion.

The fix is simple. Add '-u elastic' after the '-XPUT' command. Where 'elastic' is the default username for X-pack. After running the command you should be prompted for a password. Use the password to authenticate. Default password is 'changeme'.

Example:

curl -XPUT -u elastic http://localhost:9200/shakespeare -d '
{
 "mappings" : {
  "_default_" : {
   "properties" : {
    "speaker" : {"type": "string", "index" : "not_analyzed" },
    "play_name" : {"type": "string", "index" : "not_analyzed" },
    "line_id" : { "type" : "integer" },
    "speech_number" : { "type" : "integer" }
   }
  }
 }
}
';
1 Like

Thanks for sharing your solution, Ryan! To speed things up a bit, you can also pass the username and password as a single argument: -u elastic:changeme.

CJ

1 Like

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.