Pass multipart data in REST POST request

Hi,

I want to pass a file as a multi part content. Following is my code:

###########Start of code##############
require ‘rubygems’
require ‘rest_client’

request = RestClient::Request.new(
:method => :post,
:url => ‘https://10.99.133.54:8281/vco/api/plugins/’,
:user => ‘vadmin’,
:password => ‘vadmin’,
:accept => ‘application/xml’,
:Accept_Encoding => ‘gzip, deflate’,
:Accept_Charset => ‘ISO-8859-1,utf-8;q=0.7,*;q=0.7’,
:content_type => ‘application/zip’,
:payload => {
:multipart => true,
:file =>
File.new(“C:\plugins\o11nplugin-powershell-1.0.1.vmoapp”)
})
response = request.execute

puts response.headers
puts response.status
puts response.body
###########End of code##############

The file ‘o11nplugin-powershell-1.0.1.vmoapp’ is a binary file.

I am getting error:

C:/Ruby200/lib/ruby/gems/2.0.0/gems/rest-client-1.6.7/lib/restclient/abstract_re
sponse.rb:48:in return!': 500 Internal Server Error (RestClient::InternalServer Error) from C:/Ruby200/lib/ruby/gems/2.0.0/gems/rest-client-1.6.7/lib/restclien t/request.rb:230:inprocess_result’
from
C:/Ruby200/lib/ruby/gems/2.0.0/gems/rest-client-1.6.7/lib/restclien
t/request.rb:178:in block in transmit' from C:/Ruby200/lib/ruby/2.0.0/net/http.rb:852:instart’
from
C:/Ruby200/lib/ruby/gems/2.0.0/gems/rest-client-1.6.7/lib/restclien
t/request.rb:172:in transmit' from C:/Ruby200/lib/ruby/gems/2.0.0/gems/rest-client-1.6.7/lib/restclien t/request.rb:64:inexecute’
from importPlugin.rb:17:in `’

Can anybody please help me to understand the issue and write a multipart
content in the REST request?

Regards,
Shubhada

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs