Skip to content

Instantly share code, notes, and snippets.

@spark2010
Created October 20, 2017 08:39
Show Gist options
  • Save spark2010/46203391a5e2b465c0b95da6ea6efaef to your computer and use it in GitHub Desktop.
Save spark2010/46203391a5e2b465c0b95da6ea6efaef to your computer and use it in GitHub Desktop.
Demonstration of calling an API hosted in Knowru using Ruby
require 'uri'
require 'net/http'
uri = URI('https://www.knowru.com/api/runnable/your-is-prime-api-name/run/')
http = Net::HTTP.new(uri.host, uri.port)
req = Net::HTTP::Post.new(uri, 'Authorization' => 'Token your-token', 'Content-Type' => 'application/json', 'Accept' => 'application/json')
req.body = {input: {number: 3}}.to_json
res = http.request(req)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment