我尝试了silverstripe 4的Restfulapi插件,我的配置是:
integre\About:
api_access: true
integre\Home:
api_access: true
Image:
api_access: true
File:
api_access: true
integre\Theatre:
api_access: true
# RestfulAPI config
Colymba\RESTfulAPI\RESTfulAPI:
authentication_policy: false
access_control_policy: 'ACL_CHECK_CONFIG_AND_MODEL'
cors:
Enabled: true
Allow-Origin: '*'
Allow-Headers: '*'
Allow-Methods: 'OPTIONS, POST, GET, PUT, DELETE'
Max-Age: 86400但当我尝试http://localhost/integre/api/Theatre/1时,收到{“代码”:400,“消息”:“模型不存在。收到‘剧院’。”}
如何解决这个问题?
发布于 2019-06-04 09:42:16
您的问题是,您正在使用一个命名空间类,但没有正确地将其配置为在API中使用,因此无法正确解析。查看DefaultQueryHandler,您需要define a class name map for this
Colymba\RESTfulAPI\QueryHandlers\DefaultQueryHandler:
models:
Theatre: integre\Theatre这将告诉查询处理程序在被要求提供Theatre模型时加载integre\Theatre。请注意,配置中的Image和File引用也缺少其名称空间。
https://stackoverflow.com/questions/56414205
复制相似问题