# Error 400 when using API to create index pattern

**URL:** https://discuss.elastic.co/t/error-400-when-using-api-to-create-index-pattern/316791
**Category:** Kibana
**Created:** [October 17, 2022, 1:33pm UTC](https://discuss.elastic.co/t/error-400-when-using-api-to-create-index-pattern/316791 "2022-10-17T13:33:30Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![JorisV](https://avatars.discourse-cdn.com/v4/letter/j/a3d4f5/32.png) [@JorisV](https://discuss.elastic.co/u/JorisV)
#### Post date: [October 17, 2022, 1:33pm UTC](https://discuss.elastic.co/t/error-400-when-using-api-to-create-index-pattern/316791/1 "2022-10-17T13:33:31Z")

</div>

Hi, i'm trying to use Kibana API to create an index pattern with a specific ID.  
Here's my code

```auto
var req0 = new XMLHttpRequest();
var req1 = new XMLHttpRequest();
req0.open("DELETE","https://my.server/kb/api/index_patterns/index_pattern/8760a880-08f2-11ed-9767-e59c7669e326",false);
req0.setRequestHeader("Content-Type", "application/json")
req0.setRequestHeader("kbn-xsrf", "true")
req0.send();
req1.open("POST","https://my.server/kb/api/index_patterns/index_pattern",false);
req1.setRequestHeader("Content-Type", "application/json")
req1.setRequestHeader("kbn-xsrf", "true")
req1.send(JSON.stringify({"index-pattern":{"title": "jv-index_example*", "id": "8760a880-08f2-11ed-9767-e59c7669e326"}}));

```

DELETE request works well but POST request returns `[request body.index_pattern.title]: expected value of type [string] but got [undefined]`  
Any idea ?  
Thanks !  
Joris

---

<div class="post-metadata">

### Author: ![JorisV](https://avatars.discourse-cdn.com/v4/letter/j/a3d4f5/32.png) [@JorisV](https://discuss.elastic.co/u/JorisV)
#### Post date: [October 18, 2022, 9:34am UTC](https://discuss.elastic.co/t/error-400-when-using-api-to-create-index-pattern/316791/2 "2022-10-18T09:34:52Z")

</div>

"index\_pattern" and not "index-pattern"... my bad

---

<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: [November 15, 2022, 9:35am UTC](https://discuss.elastic.co/t/error-400-when-using-api-to-create-index-pattern/316791/3 "2022-11-15T09:35:30Z")

</div>

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