Search code examples
ruby-on-railsjsonpostactiveresource

Rails active resource: how to send post parameters in the request body and not as query strings?


I am calling some post request using rails activeresource, however all the parameters are sent as query string and the result is that the called url is too long and I get WEBrick::HTTPStatus::RequestURITooLarge exception.

So I need to send the parameters in the request body instead, however I couldn't find how to do this.

Thanks a lot


Solution

  • To send a post request in activeresource you should reference the documentation

    For example you can do this

    #Entity.post(custom_method_name, options = {}, body = '')
    Company.post(:add_role, nil, {user_id: 1, role_id: 2}.to_json)
    

    Tell me if you need anything else.