2
我試圖從ruby應用發出POST請求,並且出現以下錯誤。發佈請求中的Ruby NoMethodError(未定義的方法`map')
下面是代碼:
def action_reply(token,action_id,reply_text)
require 'uri'
require 'net/http'
require 'net/https'
@reply = { 'ACTION_ID' => action_id, 'text' => reply_text }.to_json
#A token is required to do this post
@token_url = 'https://example.com/reply?oauth_token=' + token
uri = URI.parse(@token_url)
response = Net::HTTP.post_form(uri,@reply)
end
我得到一個錯誤的最後一步,說:
NoMethodError (undefined method `map' for #<String:0x000000063798e8>)
任何想法,這是爲什麼?
謝謝!
謝謝,這工作! (關於實例變量,我只是想讓這個例子清楚) – MrJacket