3

How can I get the related entity Id instead of resource path?

For example, here's what I get now:

{
  "id": "/api/articles/0d8cb40c-221b-4c54-9e29-43877093b839",
  "type": "Article",
  "attributes": {
    "_id": "0d8cb40c-221b-4c54-9e29-43877093b839",
    "title": "Article",
    "content": "<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit.</p>",
    "dateCreated": "2018-07-17T18:20:29+03:00",
    "dateUpdated": "2018-07-17T18:20:29+03:00"
  },
  "relationships": {
    "author": {
      "data": {
        "type": "User",
        "id": "/api/users/b26e0381-6800-4f47-b269-9a92b27ad331"
      }
    }
  }
}

I would like to get related entity id like this:

"relationships": {
"author": {
  "data": {
    "type": "User",
    "id": "b26e0381-6800-4f47-b269-9a92b27ad331"
  }
}

1 Answer 1

5

API Platform 3 deprecated the allow_plain_identifiers option, but there is now a documentation page dedicated to this topic.

With API Platform 2, you can use the following configuration:

api_platform:
    allow_plain_identifiers: true

But note that:

Sign up to request clarification or add additional context in comments.

2 Comments

Support for allow_plain_identifiers has been removed, Does not work now.
@Rayiez I just updated the answer for API Platform 3.

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.