2013-04-30 11 views
0

如果我使用curl命令向github api發出POST請求以添加「Resolved」標籤;事情很好。寫一個捲曲在Ruby中發送郵件

curl -i -H "Authorization: token xxxxxxxxxxxx" -X POST 'https://git.corp.yahoo.com/api/v3/repos/owner/repo/issues/1/labels' -d '["Resolved"]'} 

但是,當我嘗試做使用curl容易同在我的Ruby腳本

set gh_api = https://git.corp.yahoo.com/api/v3/repos/owner/repo/issues/1/labels 
curl = Curl::Easy.http_post(settings.gh_api,'["Resolved"]') 
do |c| 
    c.headers = ["Authorization: token xxxxxxxx"] 
end 

的JSON效應初探我得到的是

"{\"message\":\"Not Found\"}" 

我在做什麼錯在我的紅寶石腳本?

+0

你的問題是? – 2013-04-30 19:17:39

+0

@TheTinMan編輯我的問題,使其更清晰。這有意義嗎? – Praveen 2013-04-30 19:20:49

回答

0

根本不清楚你問什麼問題,因爲毫無疑問。

返回的是JSON響應。你爲什麼不使用JSON類解析它,看看它返回:

require 'json' 

puts JSON["{\"message\":\"Not Found\"}"] 
=> {"message"=>"Not Found"} 

我猜測,這個問題是在URL路徑如果響應「未找到」。

0

我的網址有誤。我用'/'結束了URL。