尝试插入与另一个文档相关的文档时遇到一些问题。API引发了一个完全没有详细信息的异常。在
我得到了以下奇怪的问题:
"_error": {
"code": 422,
"message": "Insertion failure: 1 document(s) contain(s) error(s)"
},
"_issues": {
"exception": "'application'"
},
我使用的是python3.4、eve0.5.3和mongodb3。详情如下:
架构:
^{pr2}$所以交货和申请之间有一种关系。在这里,我将发布一个应用程序(我正在使用httpie,请参见https://github.com/jakubroztocil/httpie):
$ http POST :5000/api/applications label="toto"
回应:
HTTP/1.0 201 CREATED
Content-Length: 252
Content-Type: application/json
Date: Wed, 13 May 2015 08:35:14 GMT
Server: Eve/0.5.3 Werkzeug/0.10.4 Python/3.4.3
{
"_created": "2015-05-13",
"_etag": "fc6492cb6ba36424a9e38113026c33e49a60189d",
"_id": "55530cc2962bf270efba95b2",
"_links": {
"self": {
"href": "applications/55530cc2962bf270efba95b2",
"title": "application"
}
},
"_status": "OK",
"_updated": "2015-05-13"
}
现在,如果我尝试使用先前插入的对象中的_id
插入传递,则会引发异常:
$ http POST :5000/api/deliveries label="toto" app="55530cc2962bf270efba95b2"
回应:
HTTP/1.0 422 UNPROCESSABLE ENTITY
Content-Length: 153
Content-Type: application/json
Date: Wed, 13 May 2015 08:39:42 GMT
Server: Eve/0.5.3 Werkzeug/0.10.4 Python/3.4.3
{
"_error": {
"code": 422,
"message": "Insertion failure: 1 document(s) contain(s) error(s)"
},
"_issues": {
"exception": "'application'"
},
"_status": "ERR"
}
您的
data_relation
引用了错误的资源(端点)根据您的POST请求(因为您没有发布您的}定义定义为资源,因此您应该在数据关系中引用{}(复数)。在
DOMAIN
定义),您最终将applications
和{请尝试以下更新:
相关问题 更多 >
编程相关推荐