Eve:405 方法不允许用于 PATCH 请求

Eve: 405 Methods not allowed for PATCH request

我试图在 Eve 上禁用 concurrency-control 并尝试添加另一个新的 id_field: "new_field",但我无法让它工作。我在 Whosebug 中查看了各种 post 但我仍然无法修复它。有人可以帮忙吗?

我在全局配置中禁用了: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,
}

这里是 url 我正在尝试发送 PATCH 请求:

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

这里

resource: my resource name
end_point: id_field value.

有人可以帮忙吗

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

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

此外,您不希望在与 id_field 相同的字段上设置 additional_lookup,因为额外的查找是 read-only.

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

ITEM_URL: URL rule used to construct default item endpoint URLs. Can be overridden by resource settings. Defaults regex("[a-f0-9]{24}") which is MongoDB standard Object_Id format.