Конечная точка регистрации пользователя Dwolla с Ruby Mechanize

У меня есть приложение Ruby-On-Rails, которое я пытаюсь подключить к Dwolla с помощью Mechanize.

agent = Mechanize.new 
agent.keep_alive = false 
agent.log = Logger.new $stderr 
agent.agent.http.debug_output = $stderr 
ajax_headers = { 'X-Requested-With' => 'XMLHttpRequest', 'Content-Type' => 'application/json; charset=utf-8', 'Accept' => 'application/json, text/javascript, */*'} 
response = agent.post( "https://www.dwolla.com/oauth/rest/tes...", query_string.to_json, ajax_headers) 

Ответ, который я получаю:

Conn close because of error Connection reset by peer 

Это параметры, которые я отправляю:

{\"password\":\"Password1\",\"confirm_password\":\"Password1\",\"pin\":\"1234\",\"firstName\":\"firstName\",\"lastName\":\"lastName\",\"address\":\"address\",\"address2\":null,\"city\":\"Troy\",\"state\":\"NY\",\"zip\":\"12180\",\"phone\":\"111-123-4567\",\"dateOfBirth\":\"10/15/1970\",\"type\":\"Personal\",\"organization\":null,\"ein\":null,\"acceptTerms\":true,\"client_id\":\"foo\",\"client_secret\":\bar\"}" 

И вот что запротоколировано:

Net::HTTP::Post: /oauth/rest/testapi/register
request-header: accept => application/json, text/javascript, */*
request-header: user-agent => Mechanize/2.5.1 Ruby/1.9.2p290 (http://github.com/tenderlove/mechanize/)
request-header: connection => close
request-header: accept-encoding => gzip,deflate,identity
request-header: accept-charset => ISO-8859-1,utf-8;q=0.7,*;q=0.7
request-header: accept-language => en-us,en;q=0.5
request-header: host => www.dwolla.com
request-header: content-type => application/json; charset=utf-8
request-header: content-length => 444
opening connection to www.dwolla.com...
opened
<- "POST /oauth/rest/testapi/register HTTP/1.1\r\nAccept: application/json, text/javascript, */*\r\nUser-Agent: Mechanize/2.5.1 Ruby/1.9.2p290 (http://github.com/tenderlove/mechanize/)\r\nConnection: close\r\nAccept-Encoding: gzip,deflate,identity\r\nAccept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.7\r\nAccept-Language: en-us,en;q=0.5\r\nHost: www.dwolla.com\r\nContent-Type: application/json; charset=utf-8\r\nContent-Length: 444\r\n\r\n"
<- "{\"password\":\"Password1\",\"confirm_password\":\"Password1\",\"pin\":\"1234\",\"firstName\":\"firstName\",\"lastName\":\"lastName\",\"address\":\"address\",\"address2\":null,\"city\":\"Cohoes\",\"state\":\"NY\",\"zip\":\"12047\",\"phone\":\"111-123-4567\",\"dateOfBirth\":\"9/13/1973\",\"type\":\"Personal\",\"organization\":null,\"ein\":null,\"acceptTerms\":true,\"client_id\":\"foo\",\"client_secret\":\"bar\"}"
Conn close because of error Connection reset by peer

Любая помощь будет принята с благодарностью!


person robot_man    schedule 11.01.2013    source источник


Ответы (1)


Я полагаю, что вы используете старую [неподдерживаемую] конечную точку. Попробуйте удалить эту часть "/testapi" из URL-адреса... В любом случае, документация по этому методу также включает встроенную консоль, которая должна помочь вам начать работу с этим: https://developers.dwolla.com/dev/docs/register/register

person Michael Schonfeld    schedule 14.01.2013