I'm trying to use refine.dev with Api-platform, but all the responses are in JSON-LD, and I need them as simple JSON.
How can I configure that?
CodePudding user response:
When you are declaring your collectionOperations or itemOperiation in your entity you can set the needed formats.
collectionOperations: [
'get ' => [
'formats' => ['json'],
],
You can look at this documentation https://api-platform.com/docs/core/content-negotiation/
CodePudding user response:
You need to send requests specifying Header Accept: application/json
GET /api/action
Host: example.com
Accept: application/json
Content-Type: application/json
Content-Length: 48
If you want json to be the default in Swager UI, then you can specify the type globally in the config/packages/api_platform.yaml
file
api_platform:
formats:
json: ['application/json']