xml rpc - addAttachment error in XML-RPC while using Java -


my java code

import java.nio.file.files; import java.nio.file.paths; import java.util.vector; import helma.xmlrpc.*;  public class test {      private final static string server_url =         "http://confluence.xyz.com:8080/rpc/xmlrpc";      public static void main (string [] args) {         try {              xmlrpcclient server = new xmlrpcclient(server_url);              vector<object> params = new vector<object>(2);             params.add("user");             params.add("pass");                 string token = (string) server.execute("confluence2.login", params );             system.out.println(token);              vector<object> page = new vector<object>(3);             page.add(token);             page.add("~username");             page.add("test_page");              object token1 = server.execute("confluence2.getpage", page );             system.out.println(token1.hashcode());               string filename  = "c:/new folder/a.jpeg";             string contenttype = "image/jpeg";              vector<object> attachment = new vector<object>(2);             attachment.add("a.jpeg");             attachment.add(contenttype);             system.out.println(attachment);              byte[] bytes = files.readallbytes(paths.get(filename));             system.out.println(bytes);              vector<object> attach = new vector<object>(4);             attach.add(token);             attach.add(token1.hashcode());             attach.add(attachment);             attach.add(bytes);             system.out.println(attach);             server.execute("confluence2.addattachment", attach);          }          catch (exception exception) {             system.err.println("javaclient: " + exception.tostring());         }     } } 

everything works fine except on line "addattachment" called,

error is

javaclient: helma.xmlrpc.xmlrpcexception: java.lang.nosuchmethodexception: com.sun.proxy.$proxy2104.addattachment(java.lang.string, int, java.util.vector, [b) 

can me other library should using. seems helma.xmlrpc doesn't have addattachment method

i used org.apache.xmlrpc.client.xmlrpcclient , not helma concepts should same. it's not "helma.xmlrpc doesn't have addattachment method", it's you're calling addattachment() wrong parameters. try calling proper parameters listed @ https://developer.atlassian.com/confdev/confluence-rest-api/confluence-xml-rpc-and-soap-apis/remote-confluence-methods

addattachment(string token, long contentid, attachment attachment, byte[] attachmentdata)

so apache xmlrpc, partial code looks like:

    //add attachment page     byte[] bytes = fileutils.readfiletobytearray(new file(file_to_attach));     map<string, string> attachinfo = new hashmap<string, string>();     attachinfo.put("filename", filename);            attachinfo.put("contenttype", content_type);     attachinfo.put("comment", comment);      //actually add     client.execute("confluence1.addattachment", new object[]{token, pageid, attachinfo, bytes}); 

Comments

Popular posts from this blog

android - Get AccessToken using signpost OAuth without opening a browser (Two legged Oauth) -

org.mockito.exceptions.misusing.InvalidUseOfMatchersException: mockito -

google shop client API returns 400 bad request error while adding an item -