# Running Invoke-Method

**URL:** <https://discuss.elastic.co/t/running-invoke-method/192267>\
**Category:** Elasticsearch\
**Created:** [July 25, 2019, 2:20pm UTC](https://discuss.elastic.co/t/running-invoke-method/192267 "2019-07-25T14:20:30Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![jonathan01](https://avatars.discourse-cdn.com/v4/letter/j/fbc32d/32.png) [@jonathan01](https://discuss.elastic.co/u/jonathan01)\
**Post date:** [July 25, 2019, 2:20pm UTC](https://discuss.elastic.co/t/running-invoke-method/192267/1 "2019-07-25T14:20:30Z")

</div>

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](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](https://2252511c59834f50838ea41429bc8792.us-ea) ...
- 

```auto
  + 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

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)\
**Post date:** [August 22, 2019, 2:20pm UTC](https://discuss.elastic.co/t/running-invoke-method/192267/2 "2019-08-22T14:20:39Z")

</div>

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