Search
 
SCRIPT & CODE EXAMPLE
 

RUBY

call the api from ruby

# httpx2.rb
require "httpx"

response = HTTPX.post("https://jsonplaceholder.typicode.com/posts", :json => {'title' => 'foo', 'body' => 'bar', 'userID' => 1})
puts response.body if response.status == 201
Comment

call api in ruby

require 'uri'
require 'net/http'

url = URI("https://api.sygictravelapi.com/1.0/en/places/list?parents=city%3A372&level=poi&limit=100")

http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
http.verify_mode = OpenSSL::SSL::VERIFY_NONE

request = Net::HTTP::Get.new(url)
request["x-api-key"] = ENV["SYGIC_API_KEY"]
request["cache-control"] = 'no-cache'

response = http.request(request)
puts response.read_body
Comment

PREVIOUS NEXT
Code Example
Ruby :: deep copy and shallow copy in ruby 
Ruby :: ruby abs method 
Ruby :: rails if else assignment one liner 
Ruby :: generate view rails 
Ruby :: rails localhost https 
Ruby :: rails g migration foreign key optionnal 
Ruby :: rails form validation custom message 
Ruby :: ruby in array 
Ruby :: crashed" method=GET path="/" rails 
Ruby :: ruby on rails 4.2 how to add GET route 
Ruby :: ruby shortcut to self.call 
Ruby :: ruby array infinity 
Ruby :: ruby adding an item to a hash 
Ruby :: next if ruby 
Ruby :: ruby ** 
Ruby :: refactor duplicate tests rspec 
Ruby :: ruby hash except nested 
Ruby :: time loop start with non zero in ruby 
Ruby :: rspec change matcher 
Ruby :: time_ago_in_words for created_at model in rails 
R :: remove na from vector r 
R :: r import table with readr 
R :: merge several data frames in r 
R :: r create a list 
R :: nls in r 
R :: rstudio plot not showing 
R :: r replace space with 
R :: How to remove rows with inf from a dataframe in R 
R :: Remove specific data frames from R 
R :: read delim in r with lapply read.delim sep 
ADD CONTENT
Topic
Content
Source link
Name
4+6 =