Eve:405不允许PATCH请求的方法

时间:2016-01-24 02:31:00

标签: python rest eve

我尝试在夏娃上禁用concurrency-control并尝试添加另一个新的id_field: "new_field",但我无法使其正常工作。我查看了StackOverflow中的各种帖子,但我仍然无法修复它。有人可以帮忙吗?

我在全局配置中禁用了IF_MATCH = False并且:

schema = {
    "node_name": {
         "type": "string",
         "unique": True,
         "required": True,
    "node_type": {
         "type": "string",
         "required": True,       
    }
}

配置:

config = {
    'item_title': 'new_title',
    'additional_lookup': {
         'url': 'regex("[\w]+")',
         'field': 'node_name',
     },
    'id_field': "node_name",
    'schema': schema,
}

这是我试图发送PATCH请求的网址:

url: http:localhost:5000/api/v1/resource/end_point/

这里

resource: my resource name
end_point: id_field value.

有人可以帮忙。

1 个答案:

答案 0 :(得分:2)

您是否为资源启用了PATCH?默认情况下,document and collection endpoints are read-only。尝试将以下内容添加到您的配置中:

ITEM_METHODS = ['GET', 'PATCH', 'DELETE', 'PUT']

另外,您不希望在additional_lookup的同一字段上设置id_field,因为其他查找是只读的。

由于您没有使用ObjectID作为唯一键,因此您可能还需要更改文档端点的默认URL。尝试将ITEM_URL设置为正确的正则表达式:

  

ITEM_URL:用于构建默认项目端点URL的URL规则。可以通过资源设置覆盖。默认为regex("[a-f0-9]{24}"),它是MongoDB标准的Object_Id格式。

相关问题