Unable to send messages from business logic

As the title says I’ve run into a bit of a problem, from what I can see I’m unable to send messages from my business logic due to permissions.

I’m not sure what would be the best way to resolve this short of just creating an account to represent the server and giving it extra permissions and logging in with credentials in the bootstrap.

Is what I stated the best way to go about this or am I missing a key factor?

Are you talking about pub/sub messages or email messages?

Publising messages is what I’m having trouble with.

I’m just trying to use this as a bit of a workaround for the lack of client side hooks for data changes.

Please make sure you’re using synchronous API. If you could share the code you’re using, I’d be happy to review and make suggestions.

Here’s a snippet from my event handler: http://hastebin.com/pudecebuca.java

On my clients I have a popup when an exception occurs, the exception message is “User has no permission to publish message”.

Async for the hook is not checked in my business logic tab.

Try this:

    Put all the code inside of the event handler into a try/catch block, make sure to do exception.printStackTrace() in the catch block and run the handler with CodeRunner debugger. Also, make sure to check the permissions screen for the Messaging service. This is what it looks like in my app: http://monosnap.com/image/WFjvhJT6w1HPEta2fTHVh8Orjw9tlW
Regards, Mark

The way I have my roles setup is fairly restricted as this is a private application, is the server considered a non authenticated user? Would it be viable to login the server as it’s own user in the bootstrap? Or assign the server as it’s own role somehow?

By default the server is acting as a non-authenticated user. You can add the login call into the bootstap class (the one where Backendless.initApp is called) and then assign special permissions to the user whose account you use on the server-side.

Alright, I think that makes the most sense for my situation, thanks for such a quick response :slight_smile:

I’ll mark this thread as “Answered”, but please feel free to post if things are not working as you would’ve expected.