2

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?

3 Answers 3

5

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']
Sign up to request clarification or add additional context in comments.

Comments

2

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/

Comments

0

Try to use this code :

@ApiResource(formats= {"json"})

It works for me.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.