0

我有一个 Ruby-On-Rails 应用程序,我正在尝试使用 Mechanize 连接到 Dwolla

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

任何帮助将不胜感激!

4

1 回答 1

0

我相信您使用的是旧的 [不受支持的] 端点。尝试从 URL 中删除“/testapi”部分......无论如何,此方法的开发文档还包括一个内联控制台,可以帮助您开始使用:https ://developers.dwolla.com/dev/docs /注册/注册

于 2013-01-14T21:29:34.430 回答