我正在尝试使用qwest http://dreamysource.io/project/qwest将一些数据发送到 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)
})
where this.incident
is an Object
(来自 Vue.js)。
调用失败并显示406 (Not Acceptable)
错误,我理解 https://stackoverflow.com/a/14252326/903011来自 Elasticsearch 服务器的信息告诉我我想要某种格式的答案,但他无法使用。
尽管如此,调用失败(没有索引文档),所以我不确定我的理解是否正确?
如果是这样 - 要求的正确格式是什么?
The incident
对象不是正确序列化的 JSON 字符串。你需要打电话JSON.stringify(this.incident)
为了获得等效的 JSON 字符串,并指定application/json
HTTP 标头。
$.ajax({
url: 'http://example.com:9200/incidents/incidents',
type: 'POST',
data: JSON.stringify(this.incident),
dataType: 'json'
})
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)