Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/ruby/23.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
使用ruby中的rest客户端向HTTP post发送邮件时出现内部服务器错误_Ruby_Http_Rest_Post_Rest Client - Fatal编程技术网

使用ruby中的rest客户端向HTTP post发送邮件时出现内部服务器错误

使用ruby中的rest客户端向HTTP post发送邮件时出现内部服务器错误,ruby,http,rest,post,rest-client,Ruby,Http,Rest,Post,Rest Client,这是我的代码,我不知道如何调试它,因为我刚刚收到一个“内部服务器错误”: 我正在尝试将HTTP POST发送到外部ASPX: def upload uri = 'https://api.postalmethods.com/2009-02-26/PostalWS.asmx' #postalmethods URI #https://api.postalmethods.com/2009-02-26/PostalWS.asmx?op=UploadFile #http://w

这是我的代码,我不知道如何调试它,因为我刚刚收到一个“内部服务器错误”:

我正在尝试将HTTP POST发送到外部ASPX:

  def upload
    uri = 'https://api.postalmethods.com/2009-02-26/PostalWS.asmx' #postalmethods URI

    #https://api.postalmethods.com/2009-02-26/PostalWS.asmx?op=UploadFile
    #http://www.postalmethods.com/method/2009-02-26/UploadFile

    @postalcard = Postalcard.find(:last)
    #Username=string&Password=string&MyFileName=string&FileBinaryData=string&FileBinaryData=string&Permissions=string&Description=string&Overwrite=string
    filename = @postalcard.postalimage.original_filename
    filebinarydata = File.open("#{@postalcard.postalimage.path}",'rb')

    body = "Username=me&Password=sekret&MyFileName=#{filename}&FileBinaryData=#{filebinarydata}"

    @response = RestClient.post(uri,
                  body, #body as string
                  {"Content-Type" => 'application/x-www-form-urlencoded',
                   "Content-Length" => @postalcard.postalimage.size} # end headers
                 ) #close arguments to Restclient.post
  end

打开PostalMethods在其HTTP POST上有错误和bug


它只需要SOAP,所以我需要Savon。

在不了解RestClient或postalmethods API的情况下,您似乎在对SOAP服务进行标准HTTP Post,而没有进行必要的SOAP编码。看看Savon在ruby中编写SOAP的例子。是的,我是……我不知道有什么方法可以编写SOAP编码……谢谢@Steve