Error when using REST API for updating job configuration

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

Error when using REST API for updating job configuration

Yosi Kalmanson (kyosi)
Hi,
 
I'm trying to update job configuration through REST API. I'm posting the configuration file using the following code:
 
        HttpClient client = new HttpClient();
       
        String location = "http://localhost:8080/hudson/job/test10/config.xml";
          
        File f = new File("C:\\tmp\\configuration.xml");
        PostMethod filePost = new PostMethod(location);
       
        Part[] parts = {
            new FilePart(f.getName(), f)
        };
       
        filePost.setRequestEntity(
            new MultipartRequestEntity(parts, filePost.getParams())
        );
       
       
        client.executeMethod(filePost);
        System.out.println(filePost.getStatusCode() + "\n" + filePost.getResponseBodyAsString());
 
However, configuration is not getting updated. When i look into the response body i see:
 
javax.servlet.ServletException: hudson.util.IOException2: Failed to persist configuration.xml
org.kohsuke.stapler.Stapler.invoke(Stapler.java:498)
org.kohsuke.stapler.MetaClass$6.doDispatch(MetaClass.java:179)
org.kohsuke.stapler.NameBasedDispatcher.dispatch(NameBasedDispatcher.java:30)
....
 
and root cause:
 
org.xml.sax.SAXParseException: Content is not allowed in prolog.
com.sun.org.apache.xerces.internal.parsers.AbstractSAXParser.parse(AbstractSAXParser.java:1231)
com.sun.org.apache.xalan.internal.xsltc.trax.TransformerImpl.transformIdentity(TransformerImpl.java:610)
com.sun.org.apache.xalan.internal.xsltc.trax.TransformerImpl.transform(TransformerImpl.java:708)
com.sun.org.apache.xalan.internal.xsltc.trax.TransformerImpl.transform(TransformerImpl.java:313)
hudson.model.Job.doConfigDotXml(Job.java:989)
sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
java.lang.reflect.Method.invoke(Method.java:597)
org.kohsuke.stapler.Function$InstanceFunction.invoke(Function.java:176)
org.kohsuke.stapler.Function.bindAndInvoke(Function.java:92)
org.kohsuke.stapler.Function.bindAndInvokeAndServeResponse(Function.java:53)
org.kohsuke.stapler.MetaClass$1.doDispatch(MetaClass.java:73)
org.kohsuke.stapler.NameBasedDispatcher.dispatch(NameBasedDispatcher.java:30)
org.kohsuke.stapler.Stapler.invoke(Stapler.java:486)
org.kohsuke.stapler.MetaClass$6.doDispatch(MetaClass.java:179)
org.kohsuke.stapler.NameBasedDispatcher.dispatch(NameBasedDispatcher.java:30)
org.kohsuke.stapler.Stapler.invoke(Stapler.java:486)
org.kohsuke.stapler.Stapler.invoke(Stapler.java:404)
org.kohsuke.stapler.Stapler.service(Stapler.java:117)
javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
hudson.util.PluginServletFilter$1.doFilter(PluginServletFilter.java:91)
hudson.util.PluginServletFilter.doFilter(PluginServletFilter.java:83)
hudson.security.csrf.CrumbFilter.doFilter(CrumbFilter.java:47)
hudson.security.ChainedServletFilter$1.doFilter(ChainedServletFilter.java:84)
hudson.security.ChainedServletFilter.doFilter(ChainedServletFilter.java:76)
hudson.security.HudsonFilter.doFilter(HudsonFilter.java:155)
 
Any ideas?
 
Thanks,
Yosi

Reply | Threaded
Open this post in threaded view
|

Re: Error when using REST API for updating job configuration

issue_police
Hi,

This is a friendly reminder that the 'issues' list is only used for
automatic e-mail notification from the issue tracker, and not meant
for interactive discussion. Please request an observer role for the
project and add the comment to the issue, or please redirect your
e-mails to the 'users' list.

(this is an automatically generated message, and if you have a comment
about this bot itself, please contact [hidden email]

----
Java.net issue tracker auto responder

---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]