Re: Issues running a Jenkins job with parameters via jquery/ajax - api

2019-06-27 Thread Cliff Hanger
Any suggestions??


On Tuesday, June 25, 2019 at 10:07:37 PM UTC-7, Cliff Hanger wrote:
>
> Hi,
>
> I have the below code, somehow I just cant seem to pass the parameters to 
> Jenkins:
>
>
>var parameters = '{"parameter": [{"name":"id", "value": "2"}, 
> {"name":"id2", "value": "testing"}]}';
>$.ajax({
> url: "https://abc/job/test/buildWithParameters;,
> beforeSend: function(xhr) {
> xhr.withCredentials = true;
> xhr.setRequestHeader('cache-control', 'no-cache, must-revalidate, 
> post-check=0, pre-check=0');
> xhr.setRequestHeader("Authorization", "Basic " + 
> btoa("abc:***"));
> },
> type: "POST",
> dataType: "jsonp",
> contentType: "application/json; charset=utf-8",
> cache: false,
> async: false,
> processData: false,
> data: 'json='+parameters,
> success: function (data) {
> alert(JSON.stringify(data));
> },
> error: function(){
> alert("Cannot get data");
> }});
>
>
>
> Can someone please help me with what am I doing wrong? Also it always goes 
> in the error function and not in the success, why is that the case?
>
> --Ishan
>
>

-- 
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 jenkinsci-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/jenkinsci-users/4a4aeaac-f0d3-44d6-9fa4-c5cf92da%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Issues running a Jenkins job with parameters via jquery/ajax - api

2019-06-25 Thread Cliff Hanger
Hi,

I have the below code, somehow I just cant seem to pass the parameters to 
Jenkins:


   var parameters = '{"parameter": [{"name":"id", "value": "2"}, {"name":"id2", 
"value": "testing"}]}';
   $.ajax({
url: "https://abc/job/test/buildWithParameters;,
beforeSend: function(xhr) {
xhr.withCredentials = true;
xhr.setRequestHeader('cache-control', 'no-cache, must-revalidate, 
post-check=0, pre-check=0');
xhr.setRequestHeader("Authorization", "Basic " + 
btoa("abc:***"));
},
type: "POST",
dataType: "jsonp",
contentType: "application/json; charset=utf-8",
cache: false,
async: false,
processData: false,
data: 'json='+parameters,
success: function (data) {
alert(JSON.stringify(data));
},
error: function(){
alert("Cannot get data");
}});



Can someone please help me with what am I doing wrong? Also it always goes 
in the error function and not in the success, why is that the case?

--Ishan

-- 
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 jenkinsci-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/jenkinsci-users/8d547989-5b1f-4815-ab1b-4500710ff791%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.