teratail header banner
teratail header banner
質問するログイン新規登録

質問編集履歴

3

修正

2018/11/01 06:48

投稿

kozica
kozica

スコア58

title CHANGED
File without changes
body CHANGED
@@ -23,6 +23,6 @@
23
23
  puts res.body
24
24
 
25
25
  $ruby mrk.rb
26
- 400が返ってくる
26
+ 何も表示されない
27
27
 
28
28
  ```

2

修正

2018/11/01 06:48

投稿

kozica
kozica

スコア58

title CHANGED
File without changes
body CHANGED
@@ -16,7 +16,9 @@
16
16
  req = Net::HTTP::Get.new(uri.request_uri)
17
17
  req['X-Cisco-Meraki-API-Key'] = 'key'
18
18
 
19
- res = Net::HTTP.get_response(uri)
19
+ res = Net::HTTP.start(uri.hostname, uri.port) {|http|
20
+ http.request(req)
21
+ }
20
22
 
21
23
  puts res.body
22
24
 

1

追記

2018/11/01 06:47

投稿

kozica
kozica

スコア58

title CHANGED
File without changes
body CHANGED
@@ -5,4 +5,22 @@
5
5
  どうかご教授お願いします
6
6
  curlは下記コマンドです。
7
7
 
8
- $ curl -L -H 'X-Cisco-Meraki-API-Key: <key>' -H 'Content-Type: application/json' -X GET 'https://api.meraki.com/api/v0/organizations'
8
+ $ curl -L -H 'X-Cisco-Meraki-API-Key: <key>' -H 'Content-Type: application/json' -X GET 'https://api.meraki.com/api/v0/organizations'
9
+
10
+ ```ruby
11
+ #mrk.rb
12
+ require 'net/http'
13
+ require 'uri'
14
+
15
+ uri = URI.parse('https://api.meraki.com/api/v0/organizations')
16
+ req = Net::HTTP::Get.new(uri.request_uri)
17
+ req['X-Cisco-Meraki-API-Key'] = 'key'
18
+
19
+ res = Net::HTTP.get_response(uri)
20
+
21
+ puts res.body
22
+
23
+ $ruby mrk.rb
24
+ 400が返ってくる
25
+
26
+ ```