pythonsyncano

Syncano v4 Error: "You do not have permission to perform this action"


Using the Syncano v4 Python Library, I attempted to do the following:

book_class = instance.classes.create(
  name='book',
  schema='[{"name": "title", "type": "string"}, {"name": "author", "type": "string"}]’
)

And received this error:

syncano.exceptions.SyncanoRequestError: 403 You do not have permission to perform this action.

I'm currently using the instance API key - what am I doing wrong?


Solution

  • 403 in the response usually means you are trying to access an endpoint with either non-existing key or wrong type of key.

    In this case - you cannot create classes using instance api key - using your account key is necessary. If you don't have it, you can always check it in the dashboard, or just use https://api.syncano.io/v1/account/auth/ endpoint to log in (or use api explorer: http://docs.syncano.com/v0.1/docs/account-log-in, account key will be in the response, once you pass your credentials).

    Once you have your account key, you should use it to connect to your syncano instance:

    import syncano
    from syncano.models.base import Class
    
    connection = syncano.connect(api_key="ACCOUNT_KEY")
    
    book_class = Class.please.create(
        instance_name='INSTANCE_NAME',
        name='books',
        schema=[
            {"name": "title", "type": "string"},
            {"name": "author", "type": "string"}
        ])
    

    If account key and instance name are correct this code should work fine.