Running Invoke-Method

I am trying to run the fallowing code

Invoke-RestMethod -Uri https://2252511c59834f50838ea41429bc8792.us-east-1.aws.found.io:9243/_template/uberagent?include_type_name=true -Method Put -InFile .\elasticsearch-uberagent.json -ContentType "Application/json"

the error that I am getting is

Invoke-RestMethod : {"error":{"root_cause":[{"type":"security_exception","reason":"action [indices:admin/template/put] requires authentication","header":{"WWW-Authenticate":["Bearer
realm="security"","ApiKey","Basic realm="security" charset="UTF-8""]}}],"type":"security_exception","reason":"action [indices:admin/template/put] requires
authentication","header":{"WWW-Authenticate":["Bearer realm="security"","ApiKey","Basic realm="security" charset="UTF-8""]}},"status":401}
At line:1 char:1

  • Invoke-RestMethod -Uri https://2252511c59834f50838ea41429bc8792.us-ea ...
  •   + CategoryInfo          : InvalidOperation: (System.Net.HttpWebRequest:HttpWebRequest) [Invoke-RestMethod], WebException
      + FullyQualifiedErrorId : WebCmdletWebResponseException,Microsoft.PowerShell.Commands.InvokeRestMethodCommand
    
    
    

Not sure what to do. I believe it is looking for the user and password but I am not sure where to put it
Can some one help with the syntax.
Thanks

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