Setting CLP programmatically doesn't work on existing classes

I have a class Announcement that I want to programmatically update by calling
// POST https://my-moralis-server.com/schemas/Announcement
but I get the following response back:

{
    "code": 103,
    "error": "Class Announcement already exists."
}

Note if I try to update CLP to a class that doesn’t exist it works fine, but its not the behaviour that I expected.

1 Like

Can you share more of your code that you are using?

So I am using X-Parse-Application-Id and X-Parse-Master-Key headers
and the request body looks like this:

{
  "classLevelPermissions":
  {
    "create": { "role:admin": true }
  }
}
1 Like

I think I have found what the problem was. Instead of POST, I had to use the PUT method in case class I am trying to apply CLPs already exists.

Here is a PR which updates the docs accordingly - https://github.com/MoralisWeb3/MoralisDocumentation/pull/15/files

1 Like

Thanks, I’ll look in ~1 hour at your PR.
PR is merged now.

1 Like

Thanks so much this is exactly what I was looking for!

For anyone curious, if you want to restrict all access to your table to only be usable by your cloud fns, you can PUT:

{
  classLevelPermissions: {
    find: {},
    get: {},
    create: {},
    update: {},
    delete: {},
  },
},