To send an HTTP POST request with basic authorization in Ruby, you can use the Net::HTTP module that comes with the standard library. Here's an example method that takes a URL, a payload, a username, and a password:
main.rb570 chars23 lines
Here's how you can use this method to send a POST request to https://example.com/api with a JSON payload and basic auth credentials 'username' and 'password':
main.rb179 chars8 lines
gistlibby LogSnag