Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/visual-studio-code/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python卷曲到弹性搜索问题_Python_Curl_<img Src="//i.stack.imgur.com/RUiNP.png" Height="16" Width="18" Alt="" Class="sponsor Tag Img">elasticsearch_Kibana_Elastic Stack - Fatal编程技术网 elasticsearch,kibana,elastic-stack,Python,Curl,elasticsearch,Kibana,Elastic Stack" /> elasticsearch,kibana,elastic-stack,Python,Curl,elasticsearch,Kibana,Elastic Stack" />

Python卷曲到弹性搜索问题

Python卷曲到弹性搜索问题,python,curl,elasticsearch,kibana,elastic-stack,Python,Curl,elasticsearch,Kibana,Elastic Stack,我试图在python中使用curl在弹性搜索中推动此命令,以便在代码完成后创建索引模式 import pycurl import urllib import urllib2 apiURL = 'http://localhost:9200/.kibana/index-pattern/james+_alerts* -d' c = pycurl.Curl() c.setopt(c.URL, apiURL)

我试图在python中使用curl在弹性搜索中推动此命令,以便在代码完成后创建索引模式

        import pycurl
        import urllib
        import urllib2
        apiURL = 'http://localhost:9200/.kibana/index-pattern/james+_alerts* -d'
        c = pycurl.Curl()
        c.setopt(c.URL, apiURL)
        c.setopt(c.POSTFIELDS, '{"title" : james+"_alerts*",  "timeFieldName": "timeStamp"}')
        c.setopt(c.VERBOSE, True)
        c.perform()     
        c.close()
返回的输出是:-

*   Trying 127.0.0.1...
* TCP_NODELAY set
* Connected to localhost (127.0.0.1) port 9200 (#0)
> POST /.kibana/index-pattern/james+_alerts* -d HTTP/1.1
Host: localhost:9200
User-Agent: PycURL/7.43.0 libcurl/7.52.1 GnuTLS/3.5.6 zlib/1.2.11 libidn2/0.16 libpsl/0.17.0 (+libidn2/0.16) librtmp/2.3
Accept: */*
Content-Length: 56
Content-Type: application/x-www-form-urlencoded

* upload completely sent off: 56 out of 56 bytes
* HTTP 1.0, assume close after body
< HTTP/1.0 400 Bad Request
< content-type: application/json; charset=UTF-8
< content-length: 207
< 
* Curl_http_done: called premature == 0
* Closing connection 0
{"error":{"root_cause":[{"type":"illegal_argument_exception","reason":"invalid version format: -D HTTP/1.1"}],"type":"illegal_argument_exception","reason":"invalid version format: -D HTTP/1.1"},"status":400}
*正在尝试127.0.0.1。。。
*TCP_节点集
*已连接到本地主机(127.0.0.1)端口9200(#0)
>POST/.kibana/index pattern/james+\u警报*-d HTTP/1.1
主机:localhost:9200
用户代理:PycURL/7.43.0 libcurl/7.52.1 GnuTLS/3.5.6 zlib/1.2.11 libidn2/0.16 libpsl/0.17.0(+libidn2/0.16)librtmp/2.3
接受:*/*
内容长度:56
内容类型:application/x-www-form-urlencoded
*上传已完全发送:56个字节中的56个
*HTTP 1.0,假设在正文之后关闭

这可能是什么问题和解决方法?

您在APIRL中有额外的'-d'。我猜它来自于从命令行复制和粘贴。如果没有,则必须对url进行编码(urllib.urlencode)