Unable to lock post with API

The code is

params[:locked] === "true" ? locker.lock : locker.unlock

Which seems to be doing a string compare.

That means that you would need to send "locked": "true" and not "locked": true and that the documentation or code would need to be updated to reflect or change this behavior.

The browser does not send a JSON request, it sends Content-Type: application/x-www-form-urlencoded which will interpret the parameter as a string, and that is why it does work in the browser.