For the error that you’re getting with the raw ruby code, the problem is that the Api-Key and Api-Username need to be set in the request headers. The API field names also need to use dashes (-) instead of underscores (_). Have a look at the Authentication section at the top of https://docs.discourse.org/ for details about how to authenticate the request.
I’m not sure what would be causing the error when you make the call with the Discourse API gem. The most likely cause of the problem is that you aren’t using the correct API credentials. Make sure that you are using an API key that has its User Level set to All Users:
If that doesn’t solve the problem for you, post the request that you’re trying to make here and I’ll have a look at it.
