Search Saved Object API

I am trying to create a search saved object with the following command:
curl -X POST -H 'kbn-xsrf: true' -H 'Content-Type: application/json' 'http://localhost:5601/api/saved_objects/search/cnv' -d @stam.json

I am hitting an error:
{"message":"failed to parse field [search.kibanaSavedObjectMeta.searchSourceJSON] of type [text]: [mapper_parsing_exception] failed to parse field [search.kibanaSavedObjectMeta.searchSourceJSON] of type [text]","statusCode":400,"error":"Bad Request"}

stam.json file:

    "attributes":{
        "title":"cnv",
        "description":"",
        "hits":0,
        "columns":[
            "name"
        ],
        "sort":[
            "_score",
            "desc"
        ],
        "version":1,
        "kibanaSavedObjectMeta":{
            "searchSourceJSON":{
                "index":"cnv",
                "highlightAll":true,
                "version":true,
                "query":{
                    "language":"lucene",
                    "query":""
                },
                "filter":[]
            }
        }
    }
}

Hi @lioramilbaum

The searchSourceJSON has to be a string - could you try

 "attributes":{
        "title":"cnv",
        "description":"",
        "hits":0,
        "columns":[
            "name"
        ],
        "sort":[
            "_score",
            "desc"
        ],
        "version":1,
        "kibanaSavedObjectMeta":{
            "searchSourceJSON":"{\"index\":\"cnv\",\"highlightAll\":true,\"version\":true,\"query\":{\"language\":"lucene",\"query\":\"\"},\"filter\":[]}"
        }
    }
}

Right. Thanks for the info. It worked.

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