Reputation: 1
I've been trying to connect to an API for a Project in school. I'm currently using Ruby. I'm trying to connect to the API for IGDB and display video games and I just cannot. I've been getting nothing but errors. I have the keys with me, but I just cannot connect to API or even display anything. Any help to be able to help me connect would be greatly appreciated.
require 'net/https'
POST https://api.igdb.com/v4/games
Client_ID = 'Client ID'
Authorization = 'Bearer + Access Token'
http = Net::HTTP.new('api.igdb.com/v4',443)
http.use_ssl = true
request = Net::HTTP::Post.new(URI('https://api.igdb.com/v4/games'), {'Client_ID' => 'Client ID', 'Authorization' => 'Bearer access_token'})
request.body = 'fields age_ratings,aggregated_rating,aggregated_rating_count,alternative_names,artworks,bundles,category,checksum,collection,cover,created_at,dlcs,expansions,external_games,first_release_date,follows,franchise,franchises,game_engines,game_modes,genres,hypes,involved_companies,keywords,multiplayer_modes,name,parent_game,platforms,player_perspectives,rating,rating_count,release_dates,screenshots,similar_games,slug,standalone_expansions,status,storyline,summary,tags,themes,total_rating,total_rating_count,updated_at,url,version_parent,version_title,videos,websites;'
puts http.request(request).body
Errors:
(With POST https://api.igdb.com/v4/games)
C:\Users\Saad>Ruby Test2.rb
Test2.rb:2: unknown regexp options - ap
POST https://api.igdb.com/v4/games
(W/O the POST line)
C:\Users\Saad>Ruby test2.rb
Traceback (most recent call last):
9: from test2.rb:8:in `<main>'
8: from C:/Ruby27-x64/lib/ruby/2.7.0/net/http.rb:1483:in `request'
7: from C:/Ruby27-x64/lib/ruby/2.7.0/net/http.rb:932:in `start'
6: from C:/Ruby27-x64/lib/ruby/2.7.0/net/http.rb:943:in `do_start'
5: from C:/Ruby27-x64/lib/ruby/2.7.0/net/http.rb:958:in `connect'
4: from C:/Ruby27-x64/lib/ruby/2.7.0/timeout.rb:105:in `timeout'
3: from C:/Ruby27-x64/lib/ruby/2.7.0/timeout.rb:95:in `block in timeout'
2: from C:/Ruby27-x64/lib/ruby/2.7.0/net/http.rb:960:in `block in connect'
1: from C:/Ruby27-x64/lib/ruby/2.7.0/net/http.rb:960:in `open'
C:/Ruby27-x64/lib/ruby/2.7.0/net/http.rb:960:in `initialize': getaddrinfo: No such host is known. (SocketError)
9: from test2.rb:8:in `<main>'
8: from C:/Ruby27-x64/lib/ruby/2.7.0/net/http.rb:1483:in `request'
7: from C:/Ruby27-x64/lib/ruby/2.7.0/net/http.rb:932:in `start'
6: from C:/Ruby27-x64/lib/ruby/2.7.0/net/http.rb:943:in `do_start'
5: from C:/Ruby27-x64/lib/ruby/2.7.0/net/http.rb:958:in `connect'
4: from C:/Ruby27-x64/lib/ruby/2.7.0/timeout.rb:105:in `timeout'
3: from C:/Ruby27-x64/lib/ruby/2.7.0/timeout.rb:95:in `block in timeout'
2: from C:/Ruby27-x64/lib/ruby/2.7.0/net/http.rb:960:in `block in connect'
1: from C:/Ruby27-x64/lib/ruby/2.7.0/net/http.rb:960:in `open'
C:/Ruby27-x64/lib/ruby/2.7.0/net/http.rb:960:in `initialize': Failed to open TCP connection to api.igdb.com/v4:443 (getaddrinfo: No such host is known. ) (SocketError)
Upvotes: 0
Views: 1210
Reputation: 133
Someone asked Dhruv Shah which wrapper you could use. The igdb documentation recommends this wrapper for ruby.
Upvotes: 0