尝试加载CSV数据时出现RESTHeart错误



我尝试使用加载csv数据

given().
contentType("text/csv").
body("num,name,valn1,dror,xn2,amir,y").
when().
log ().
all ().
post("csv?db=restheart&coll=poi&id=0").
then().log().ifError()

我得到状态400:

"message": "Content-Type request header must be 'text/csv'"

尽管标题似乎是正确的:

Content-Type=text/csv; charset=ISO-8859-1

完整日志如下:

Request path:   http://localhost:8080/csv?db=restheart&coll=poi&id=0
Proxy:          <none>
Request params: <none>
Query params:   <none>
Form params:    <none>
Path params:    <none>
Multiparts:     <none>
Headers:        Accept=*/*
Content-Type=text/csv; charset=ISO-8859-1
Cookies:        <none>
Body:
num,name,val
1,dror,x
2,amir,y
HTTP/1.1 400 Bad Request
Content-Encoding: gzip
X-Powered-By: restheart.org
Auth-Token-Location: /tokens/admin
Authentication-Info: nextnonce="moqjKcH05wkNMTU4NTk1NDY2OTEwNe2jU1Xuay1TK5O7rrmyiDA=",qop="auth",rspauth="d31b66e99f7dbb1c339b17741f9380c5",cnonce="f1843d31ec429268",nc=00000001
Access-Control-Expose-Headers: Location, ETag, X-Powered-By, Auth-Token, Auth-Token-Valid-Until, Auth-Token-Location
Date: Fri, 03 Apr 2020 22:57:49 GMT
Auth-Token: 16p0go30vzwa3ju0h839zn4wfnipcy914g56b5t0xkjh9yotxa
Connection: keep-alive
Access-Control-Allow-Origin: *
Auth-Token-Valid-Until: 2020-04-03T23:12:49.109466Z
Access-Control-Allow-Credentials: true
Content-Type: application/json
Content-Length: 142
{
"http status code": 400,
"http status description": "Bad Request",
"message": "Content-Type request header must be 'text/csv'",
"_links": {
"self": {
"href": "/csv"
}
}
}

知道出了什么问题吗?

我检查了CsvLoader服务(处理请求(的代码,它检查内容类型是否正好是text/csv,所以我认为问题出在附加的字符集子字符串; charset=ISO-8859-1

强制Content-Type标头恰好为text-cvs

我还修复了这个错误(请参阅提交47fa0821(。修正将包含在即将发布的v5.0版本中。

最新更新