1
votes

I try the Restfulapi addon for silverstripe 4 and my configuration is:

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

but when i try http://localhost/integre/api/Theatre/1 i receive { "code": 400, "message": "Model does not exist. Received 'Theatre'." }

how to fix this?

1

1 Answers

2
votes

Your problem is that you're using a namespaced class and not correctly configuring it to be used in the API, so it's not resolving correctly. Looking at DefaultQueryHandler, you need to define a class name map for this:

Colymba\RESTfulAPI\QueryHandlers\DefaultQueryHandler:
  models:
    Theatre: integre\Theatre

This tells the query handler to load integre\Theatre when it is asked for a Theatre model. Note that your Image and File references in your configuration are also missing their namespaces.