I've managed to create an index with a curl statement. I was able to to create a visualization, export the json, deleted the visualization, and now I am trying to add it again with a curl statement:
My statement: curl -X POST -d '@test.json' http://localhost:5601/api/saved_objects/visualization/test
Error:
{"statusCode":400, "error":"Bad Request", "message":"Request must contain a kbn-xsrf header."}
next attempt: curl -X POST -d '@test.json' -H 'kbn-xsrf:true' http://localhost:5601/api/saved_objects/visualization/test
Error:
{"statusCode":400,"error":"Bad Request","message":child "attributes" fails because ["attributes" is required]. .....}
I'm not familiar with the API really, but from that pull you linked to, the body of the JSON you have isn't right. In the description of the pull, the following is used:
There's a top-level attributes property which contains the information about the saved object. That would explain the error you are seeing ("attributes" is required).
I updated the json to reflect what you have there and indeed I got new errors. I also tried the same json that gets exported from kibana after creation and got the same errors.
curl:
curl -X POST -d '@test.json' -H 'kbn-xsrf:true' http://localhost:5601/api/saved_objects/visualization/test
error:
Warning: Couldn't read data from file "test.json", this makes an empty POST.
{"statusCode":400,"error":"Bad Request","message":"child \"attributes\" fails because {\"attributes\" is required,"validation":{""source":"payload","keys":["attributes"]}}
Warning: Couldn't read data from file "test.json", this makes an empty POST.
{"statusCode":400,"error":"Bad Request","message":"\"value\" must be an object","validation":{"source":"payload","keys":["value"]}}
Warning: Couldn't read data from file "test.json", this makes an empty POST.
Something is wrong with the way you're using curl. That is a curl error... are you sure you have the path right for that file? As it is, your sending a request with an empty body, so any error you see in the response isn't useful.
I was having two separate problems here. My json was not in the format that kibana wanted and my curl statement was not forming the request correctly.
After I created the visualization in kibana and exported it using the UI I was left with a clean JSON. I was trying to use the source{} part of the JSON but, as @Joe_Fleming mentioned, I was missing the attributes. The JSON needed to be edited to fit the following format for my statement:
Apache, Apache Lucene, Apache Hadoop, Hadoop, HDFS and the yellow elephant
logo are trademarks of the
Apache Software Foundation
in the United States and/or other countries.