Ok, it seems that you need to add xmlHttp.setRequestHeader('Content-type',
'application/x-www-form-urlencoded');2013/5/30 Louis Roché <[email protected]> > Hi, > > I try to trigger a job via the api with a parameter. > > With curl, it works: > > curl -X POST " > http://192.168.5.230:8080/job/Generate%20new%20reference%20files/build?token=toto" > --data > 'json={"parameter":[{"name":"exchange_revision","value":"superargument"}]}' > > But I want to do it from javascript. > > <html> >> <meta http-equiv="content-type" content="text/html; charset=utf-8" /> >> <script> >> function httpPost(theUrl, Params) >> { >> var xmlHttp = null; >> >> xmlHttp = new XMLHttpRequest(); >> alert(Params); >> xmlHttp.open( "POST", theUrl, false ); >> xmlHttp.send( Params ); >> return xmlHttp.responseText; >> } >> </script> >> <button >> type='button' >> onclick='javascript: >> var params = JSON.stringify({parameter: [{name: "exchange_revision", >> value: "superargument"}]}); >> var test = >> "json={\"parameter\":[{\"name\":\"exchange_revision\",\"value\":\"superargument\"}]}"; >> httpPost("http://192.168.5.230:8080/job/Generate new reference >> files/build?token=toto", test)'> >> Start matrix >> </button> >> </html> >> > > This request return a 400 and doesn't trigger the build. > > I can't use buildWithParameters cause I can have strings in UCS2, UTF8, > iso-* like 総組立. Or maybe it is possible, but I didn't find how. > > Please, help me. > > Thanks > > Louis > > -- > You received this message because you are subscribed to a topic in the > Google Groups "Jenkins Users" group. > To unsubscribe from this topic, visit > https://groups.google.com/d/topic/jenkinsci-users/kCqmG9oK58I/unsubscribe?hl=en > . > To unsubscribe from this group and all its topics, send an email to > [email protected]. > For more options, visit https://groups.google.com/groups/opt_out. > > > -- You received this message because you are subscribed to the Google Groups "Jenkins Users" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. For more options, visit https://groups.google.com/groups/opt_out.
