Error 400 when using API to create index pattern

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

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

"index_pattern" and not "index-pattern"... my bad

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