'Net::HTTPMethodNotAllowed 405 Method Not Allowed [ruby on rails]

I have the following code structure and the response shows 405 and 401 errors. I am confused about how to solve this error. I tried using 'get' and 'head' instead of 'post'.

 uri = URI(webhook_url)
    headers = { 'Content-Type': 'application/json',}.merge(optional_headers_hash)
    proxy_class = Net::HTTP::Proxy('localhost', 8080)
    proxy_class.start(uri.host, uri.port, use_ssl: true) do |proxy_http|
      req = Net::HTTP::Post.new(uri.path, headers)
      req.body = request.to_json
      res = proxy_http.request(req)
    end

error: enter image description here

I also tried the curl -I my_the_website_to_test.com following this link, but it shows connection timeout.



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source