Bugzilla - web service through JSON-RPC

Here is what I tried a lot further ..

<html>
  <head>
    <title>bugstats.com</title>
  </head>
<script type="text/javascript"     src="http://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.min.js"></script>
<script type="text/javascript" src="http://jquery-json.googlecode.com/files/jquery.json-    1.3.min.js"></script>
<script type="text/javascript" >
function hello(){
var myObject = {"method":"User.login", /* is this the right method to call? */
"params":[  { "login" :"user", /*should i include the login credentials here? */
"password" : "pass123" , 
"remember" : "True"} ]  };
var enc = $.toJSON(myObject);

$.ajax({"contentType":"application/json",
    "data": enc, 
    "crossDomain":"true",
    "dataType": "json", 
    "url": "https://bugzilla.company.com/bugzilla/jsonrpc.cgi", /* is this correct or should it be https://bugzilla.company.com/bugzilla/jsonrpc.cgi?method=User.login? */ 
    "type": "POST",
    success: function(){
            alert("Hallelujah");
                console.log(arguments); 

             },
    error: function () {
    alert("Failed")
    }

   });
}
function parseResponse(obj){
 alert("Success")
 console.log(obj)
}
</script>
  <body>
    <h1>bugzilla.com</h1>
    <input type="button" onclick="hello()" value="Click">
</body>

Reading this JSONPRC is not going far.

When I press the button - I make a call to enter / do something in this regard - I get the following error -

OPTIONS https://bugzilla.company.com/bugzilla/jsonrpc.cgi 403 (Forbidden) jquery.min.js:19
XMLHttpRequest cannot load https://bugzilla.company.com/bugzilla/jsonrpc.cgi. Origin http://172.16.229.137 is not allowed by Access-Control-Allow-Origin.

In my opinion, "Access-Control-Allow-Origin" is called due to "the same problem with the original policy" and therefore I have to use "jsonp". But Jsonp injection - ie, script can only be executed with a GET request. But if I try the same JS script with a GET request, I get the following:

code: 32610
message: "For security reasons, you must use HTTP POST to call the 'User.login' method."

, / -, , , - , - .. , - . 8-10 ..:(

FYI:

  • Bugzilla

,

Ajax Call

Loggin In

BugzillaApc

Google -

+5
1

Bugzilla_login Bugzilla_password , GET jsonp. , User.get :

// Method parameters
var params = [{
  /* The authentication parameters */
  "Bugzilla_login": "YourUserName",
  "Bugzilla_password": "YourPassword",
  /* The actual method parameters */
  "ids": [1, 2]
}];
var myObject = {
  "method": "User.get",
  "params": JSON.stringify(params)
};

$.ajax({"contentType": "application/json",
    "data": myObject, /* jQuery will handle URI encoding */
    "crossDomain": "true",
    "dataType": "jsonp", /* jQuery will handle adding the 'callback' parameter */
    "url": "https://bugzilla.company.com/bugzilla/jsonrpc.cgi", 
    "type": "GET",
    ...

, :

  • , Access-Control-Allow-Origin, jsonp ( , jsonp ).
  • jsonp GET, POST

:

+5

All Articles