Privateattributes not working to hide id column

I have been trying to hide the id column from the api response but that doesn’t seem to be working for me. I am able to hide all other columns using privateattributes options but it is not working for id. Has anyone faced the similar problem and able to solve?

1 Like

Hey, I’m having the exact same issue. In Strapi 3 we weren’t receiving the id field in nested components of an API response so our application was able to duplicate entries fairly easily.

After the Strapi 4 upgrade, this is not the behavior and it’s breaking our app duplication feature. I need to be able to hide the ID field in responses in order to duplicate entries without causing a duplicate primary key error, and without some crazy, unmaintainable workaround in our front end.

The docs show that privateAttributes can take id as a parameter but I’m still getting the id fields in every single one of my components and content types. Because of this I even tried to utilize the reviver function in JSON.parse to remove the id fields but then it was also removing the id field in our images, removing them entirely.

To make matters worse, it doesn’t seem like the privateAttributes is applicable to components, and that is absolutely something we need.

I would really appreciate a solution to this soon. If anyone knows a reliable workaround it’d be super appreciated, thanks.

Did you find the solution for this
I am also, facing the same issue
After providing in schema js

"options": {
    "draftAndPublish": false,
    "privateAttributes": ["id", "createdAt", "updatedAt"]
  },

Not able to hide ID