Ajax call error during Rally sdk custom dashboard developement

69 Views Asked by At

I'm getting 403 exception when I make an ajax call to jenkins api call to get the build details from Rally sdk custom html interface.

        //Ajax api call to jenkins
        var blink ="https://[jenkinshost]/job/Appdev/job/TestProject/api/json";
        Ext.Ajax.request({
            url: blink, 
            method :'GET',
            crossDomain: true,
            withCredentials: true,  
            headers : { 
                'Authorization': 'Basic dsasfsfxfhfj',
                 'Content-Type': 'application/json;charset=UTF-8',
            },
            success: function(response){
                var backToJs=JSON.parse(response.responseText);
                    console.log('resp data-',backToJs);
                    //console.log(backToJs['QueryResult'].Results);

            },
            failure: function(response) {
                console.log('jenkins-ajax call failure');
            }
        });

ajax call error-

Response to preflight request doesn't pass access control check: No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'https://rally1.rallydev.com' is therefore not allowed access. The response had HTTP status code 403.

1

There are 1 best solutions below

3
On

Add to your .htaccess file on both domains this string:

Header add Access-Control-Allow-Origin "*"

And try to find more information about cross-domain requests.