Missing Authentication Credentials for REST Request

Hello Elastic Users,

I am trying to check if my Elasticsearch is working fine or not by running the following command in WindowsPowershell.

Invoke-RestMethod http://localhost:9200

But it threw an 401-Authentication error. I am not sure how to pass on the credentials along with Invoke Command in Powershell.

PS C:\Users\hussshe> Invoke-RestMethod http://localhost:9200
Invoke-RestMethod : {"error":{"root_cause":[{"type":"security_exception","reason":"missing authentication credentials
for REST request [/]","header":{"WWW-Authenticate":"Basic realm="security"
charset="UTF-8""}}],"type":"security_exception","reason":"missing authentication credentials for REST request
[/]","header":{"WWW-Authenticate":"Basic realm="security" charset="UTF-8""}},"status":401}
At line:1 char:1

  • Invoke-RestMethod http://localhost:9200
  •   + CategoryInfo          : InvalidOperation: (System.Net.HttpWebRequest:HttpWebRequest) [Invoke-RestMethod], WebExc
      + FullyQualifiedErrorId : WebCmdletWebResponseException,Microsoft.PowerShell.Commands.InvokeRestMethodCommand


P.S: I am a beginner trying to learn ELK on my own.

Any help would be appreciated.

I don't know powershell, but a quick web search shows me this doesn't look easy - https://www.reddit.com/r/PowerShell/comments/gs7i4s/calling_an_api_using_invokerestmethod_using/

Unfortunately this is outside the scope of what we can assist with here sorry to say.

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