简体   繁体   中英

getting internal server error using rest-client in ruby to post to HTTP POST

this is my code and I don't know how to debug it because I just get an "internal server error":

I am trying to HTTP POST to an external 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

Turns on PostalMethods had an error and bug on their HTTP POST.

It only takes SOAP so I would need Savon.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM