# Problem creating index pattern from CURL

**URL:** https://forum.opensearch.org/t/problem-creating-index-pattern-from-curl/4555
**Category:** Open Source Elasticsearch and Kibana
**Created:** [January 11, 2021, 5:27pm UTC](https://forum.opensearch.org/t/problem-creating-index-pattern-from-curl/4555 "2021-01-11T17:27:55Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![flavio](https://avatars.discourse-cdn.com/v4/letter/f/d07c76/32.png) [@flavio](https://forum.opensearch.org/u/flavio)
#### Post date: [January 11, 2021, 5:27pm UTC](https://forum.opensearch.org/t/problem-creating-index-pattern-from-curl/4555/1 "2021-01-11T17:27:55Z")

</div>

Hi everybody, i’m trying to write a script talking with opendistro and i need to write a curl in order to create an index pattern. I tried several solutions, but the one that seems to work gives me an index-pattern that is visibile in index-pattern’s list but when i try to click on it, i can only see an empty page.

 ![image](https://us1.discourse-cdn.com/flex019/uploads/mauve_hedgehog/original/1X/5cfd13bc0606164dbbd3cbc082417e8b96319848.png)

That’s the curl i run:

> curl -X POST https’://‘$hostname’:‘$port’/‘.kibana/\_doc/doc:index-pattern:$var -u ‘admin:admin’ -k -H ‘Content-Type: application/json’ -d ’  
> {“type” : “index-pattern”,“index-pattern” : {“title”: "’$var’-\*",“timeFieldName”: “timestamp”}}')

And that’s the equivalent that i run in dev tools:

> ```
> > POST .kibana/_doc/index_pattern/
> > {
> > "type" : "index-pattern",
> > "references" : [],
> > "migrationVersion" : {
> > "index-pattern" : "7.6.0"
> > },
> > "index-pattern" : {
> > "title": "index_with_automated_retention_7*",
> > "timeFieldName": "timestamp",
> > "fields":"[]"
> > }
> > }
> 
> ```

**Anybody can help me to fix this problem?**  
I need that my index pattern will be editable.  
Thx in advance.

---

<div class="post-metadata">

### Author: ![oscark](https://sea1.discourse-cdn.com/flex019/user_avatar/forum.opensearch.org/oscark/32/866_2.png) [@oscark](https://forum.opensearch.org/u/oscark)
#### Post date: [January 12, 2021, 1:59pm UTC](https://forum.opensearch.org/t/problem-creating-index-pattern-from-curl/4555/2 "2021-01-12T13:59:03Z")

</div>

Have you tried this: [Header "securitytenant" not work properly for select tenant - #2 by oscark](https://forum.opensearch.org/t/header-securitytenant-not-work-properly-for-select-tenant/4382/2)

Also if you have multi tenant enable you probably don’t want to create the new index pattern in the .kibana-index but instead in the tenant specific index.

---

<div class="post-metadata">

### Author: ![flavio](https://avatars.discourse-cdn.com/v4/letter/f/d07c76/32.png) [@flavio](https://forum.opensearch.org/u/flavio)
#### Post date: [January 12, 2021, 5:01pm UTC](https://forum.opensearch.org/t/problem-creating-index-pattern-from-curl/4555/3 "2021-01-12T17:01:57Z")

</div>

Thx to answer my question! Figured out that something was wrong with the uri path I found online. For the ones who will look at this topic, i’m going to post the old wrong curl followed by the right one with the fix applied.

OLD CURL (WRONG):

> curl -X POST https’://’$hostname’:’$port’/’.kibana/\_doc/doc:index-pattern:$var -u ‘admin:admin’ -k -H ‘Content-Type: application/json’ -d ’  
> {“type” : “index-pattern”,“index-pattern” : {“title”: “’$var’-\*”,“timeFieldName”: “timestamp”}}’)

NEW CURL (RIGHT):

> curl -X POST https’://’$hostname’:’$port’/’.kibana/\_doc/index-pattern:$var -u ‘admin:admin’ -k -H ‘Content-Type: application/json’ -d ’  
> {“type” : “index-pattern”,“index-pattern” : {“title”: “’$var’-\*”,“timeFieldName”: “timestamp”}}’)

Essentially removed “doc:” from the uri.  
Thx to everyone.
