Merge pull request #808 from rsvato/agents

[RJA-1661] [fix] - JS: Polling stops if REST request fails
[RJA-1790] [fix] - Rest returns error code 500 instead of 403