首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >Silverstripe Restfulapi配置

Silverstripe Restfulapi配置
EN

Stack Overflow用户
提问于 2019-06-02 18:29:23
回答 1查看 105关注 0票数 1

我尝试了silverstripe 4的Restfulapi插件,我的配置是:

代码语言:javascript
复制
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,“消息”:“模型不存在。收到‘剧院’。”}

如何解决这个问题?

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2019-06-04 09:42:16

您的问题是,您正在使用一个命名空间类,但没有正确地将其配置为在API中使用,因此无法正确解析。查看DefaultQueryHandler,您需要define a class name map for this

代码语言:javascript
复制
Colymba\RESTfulAPI\QueryHandlers\DefaultQueryHandler:
  models:
    Theatre: integre\Theatre

这将告诉查询处理程序在被要求提供Theatre模型时加载integre\Theatre。请注意,配置中的Image和File引用也缺少其名称空间。

票数 2
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/56414205

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档