Created
July 26, 2016 07:55
-
-
Save hatimn02/4d8aa8b64402cf0e89506b9b305e4aea to your computer and use it in GitHub Desktop.
Ruby sample code
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require "net/http" | |
require "uri" | |
require 'json' | |
base_uri = "http://flow.viasocket.com/trigger/team/flow_identifier" #Set your Socket Api | |
base_uri = base_uri + "?param1=value1¶m2=value2" #Set query params | |
uri = URI.parse(base_uri) | |
data = { | |
status: "testing", | |
comment: "Tested via socket." | |
} | |
http = Net::HTTP.new(uri.host, uri.port) | |
request = Net::HTTP::Post.new(uri.request_uri) | |
request.add_field("Auth-Key", "SETYOURAUTHKEY") #Set your Auth-Key in header | |
request.add_field("Content-Type", "application/json") | |
request.body = data.to_json #Set json body | |
#request.set_form_data({"param1" => "value1", "param2" => "value2"}) #Set form-data if not using raw body | |
response = http.request(request) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment