On Feb 1, 2008 3:02 AM, Pieter Steyn <[EMAIL PROTECTED]> wrote:

> Could anyone please tell me what I'm doing wrong?I'm trying to upload an
> image through xmlrpc via a ruby script (have
> tried perl aswel with same results)
>
> Code:
> #Ruby code
> require 'xmlrpc/client'
> server = XMLRPC::Client.new(hostname, /roller/roller-services/xmlrpc,
> 8080)
> stuct = {}
> struct["name"] = "newpicture.jpg"
> struct["type"] = "image/jpeg"
> struct["bits"] = Base64.b64encode(File.read("newpicture.jpg"))
> server.call('metaWeblog.newMediaObject', 'blogid', 'username','password',
> struct)
>
> ERROR:
>
> XMLRPC::FaultException: XMLRPC::FaultException
>
> Failed to invoke method newMediaObject in class
> org.apache.roller.weblogger.webservices.xmlrpc.MetaWeblogAPIHandler:
> java.lang.String cannot be cast to [B
>

Looks like a are sending a String and Roller is expecting you to send a "[B"
which mean a byte.

So, I bet the problem is in the line that starts with struct["bits"]. Are
you sure you need to use that Base64 call? Maybe you are supposed to set a
byte array there and let the XMLRPC library do the encoding?

- Dave

Reply via email to