2016-12-24 2 views
0

요점 API를 임시 비교 도구로 사용하려고합니다. 이렇게하려면 일부 텍스트를 요지로 업로드 한 다음 업데이트하고 diff를 봅니다. 웬일인지 나는 "{\"message\":\"Not Found\",\"documentation_url\":\"https://developer.github.com/v3\"}"를 얻고있다. 그 약간 난 GIST를 잘 볼 수있는 URL을 볼 때 혼란.요점을 생성 한 후 바로 업데이트 할 수 없음

uri = URI("https://api.github.com/gists") 

first_payload = { 
    'description' => "My test gist", 
    'public' => true, 
    'files' => { 
     'change.yml' => { 
      'content' => "before" 
     } 
    } 
} 

req = Net::HTTP::Post.new(uri.path) 
req.body = first_payload.to_json 
req.basic_auth("username", "password") 
res = Net::HTTP.start(uri.hostname, uri.port, :use_ssl => true) do |http| 
    http.request(req) 
end 

second_uri = URI(JSON.parse(res.body)["url"]) 
second_payload = { 
    'description' => "My test gist", 
    'public' => true, 
    'files' => { 
     'change.yml' => { 
      'content' => ':after' 
     } 
    } 
} 

second_req = Net::HTTP::Put.new(second_uri.path) 
second_req.body = second_payload.to_json 
second_req.basic_auth("username", "password") 
second_res = Net::HTTP.start(second_uri.hostname, second_uri.port, :use_ssl => true) do |http| 
    http.request(second_req) 
end 

답변

0

second_req = Net::HTTP::Patch.new(second_uri.path)가 속임수를 썼는지 다음과 같이

내 코드는