elasticsearch的406(不可接受)错误代码是什么意思? [英] What does a 406 (Not Acceptable) error code from elasticsearch mean?
问题描述
我正在尝试使用 qwest
将数据发送到Elasticsearch:
I am trying to use qwest
to send some data to Elasticsearch:
qwest.post(
'http://elk.example.com:9200/incidents',
this.incident,
{cache: true}
)
.then(function (xhr, response) {
console.log('incident posted')
})
.catch(function (e, xhr, response) {
console.log('error posing incident: ' + e)
})
其中 this.incident
是对象
(来自Vue.js)。
where this.incident
is an Object
(from Vue.js).
调用失败,并显示 406(不接受)
错误,我理解,它是来自Elasticsearch服务器的信息,告诉我我想要一个答案
The call fails with a 406 (Not Acceptable)
error, which I understand being an information from the Elasticsearch server telling me that I wanted an answer in some format, which he cannot use.
尽管如此,通话还是失败了(没有索引文件),所以我不确定我是否nderstanding是正确的吗?
The call fails (there is no document indexed) nevertheless, so I am not sure if my understanding is correct?
如果是的话,什么是正确的格式?
If so - what is a correct format to ask for?
推荐答案
事件
对象不是正确序列化的JSON字符串。您需要调用 JSON.stringify(this.incident)
以获得等效的JSON字符串,并指定 application / json
HTTP标头。
The incident
object is not a properly serialized JSON string. You need to call JSON.stringify(this.incident)
in order to get the equivalent JSON string, and specify the application/json
HTTP header.
$.ajax({
url: 'http://example.com:9200/incidents/incidents',
type: 'POST',
data: JSON.stringify(this.incident),
dataType: 'json'
})
这篇关于elasticsearch的406(不可接受)错误代码是什么意思?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!