Rally Software

  • 1.  Why is my Rally API call from Java being blocked?

    Posted 04-15-2019 04:40 PM

    Hi, 

     

    I am trying to connect to the Rally API through Java in order to create an application for pulling custom reports and am following the guide for basic query requests with the toolkit for Java: 

    https://github.com/RallyTools/RallyRestToolkitForJava/wiki/User-Guide

     

    However, I am getting an error saying the URL is blocked. I have added all needed JARs to the classpath and they seem to be importing fine and have added my proxy server information. I have triple checked to see if I am completing each step in my code and made sure my API key is still active, but I can't seem to figure out the problem. Has this been seen before, or is there anything I could be missing?

     

    Stack trace:

    Exception in thread "main" java.io.IOException: HTTP/1.1 403 URLBlocked
    at com.rallydev.rest.client.HttpClient.executeRequest(HttpClient.java:163)
    at com.rallydev.rest.client.HttpClient.doRequest(HttpClient.java:145)
    at com.rallydev.rest.client.ApiKeyClient.doRequest(ApiKeyClient.java:37)
    at com.rallydev.rest.client.HttpClient.doGet(HttpClient.java:221)
    at com.rallydev.rest.RallyRestApi.query(RallyRestApi.java:172)
    at com.MakeReport.Main.main(Main.java:44)

     

    Code:

    package com.MakeReport;

    import com.rallydev.rest.RallyRestApi;
    import com.rallydev.rest.client.HttpClient;
    import com.rallydev.rest.request.QueryRequest;
    import com.rallydev.rest.response.QueryResponse;
    import com.rallydev.rest.util.Fetch;
    import com.rallydev.rest.util.QueryFilter;

    import java.io.IOException;
    import java.net.Proxy;
    import java.net.URI;
    import java.net.URISyntaxException;

    public class Main {
        public static void main (String[] args)throws URISyntaxException, IOException{
            Proxy proxy;
            RallyRestApi restApi = new RallyRestApi(new URI("https://rally1.rallydev.com"), "key");
            restApi.setApplicationName("Amex GAR Epic Report");
            HttpClient client = restApi.getClient();

            System.out.println(client);

            String version = restApi.getWsapiVersion();
            System.out.println(version);

            restApi.setProxy(new URI("url:port"));
            try {

    //            GetRequest getRequest = new GetRequest("/hierarchicalrequirement");
    //            GetResponse getResponse = restApi.get(getRequest);

                QueryRequest userStoryRequest = new QueryRequest("HierarchicalRequirement");

                userStoryRequest.setFetch(new Fetch("FormattedID", "Name", "State", "Priority", "Project"));
                userStoryRequest.setQueryFilter(new QueryFilter("Project.Name", "contains", "E_GAR_"));
                userStoryRequest.setOrder("FormattedID ASC");

                userStoryRequest.setPageSize(25);
                userStoryRequest.setLimit(100);
               
                QueryResponse queryResponse = restApi.query(userStoryRequest);
                if (queryResponse.wasSuccessful()) {
                    System.out.println(String.format("\nTotal results: %d", queryResponse.getTotalResultCount()));
                } else {
                    System.err.println("The following errors occurred: ");
                    for (String err : queryResponse.getErrors()) {
                        System.err.println("\t" + err);
                    }
                }
                System.out.println(queryResponse);
            }
            finally {
                restApi.close();
            }
        }
    }

     

    Thanks



  • 2.  Re: Why is my Rally API call from Java being blocked?
    Best Answer

    Broadcom Employee
    Posted 04-16-2019 02:27 PM

    Hi Dominic,

     

    I'm not seeing any issues with the code jumping out at me, but I suspect that it's actually your proxy server that's throwing the error.  

     

    I took a look at our logs for "Amex GAR Epic Report" but I'm not seeing that signature for the last 7 days.  This tells me that the request is never making it to our servers.

     

    You might need to check with your proxy admin and see if they're seeing anything in their logs.

     

    Thanks,
    David



  • 3.  Re: Why is my Rally API call from Java being blocked?

    Posted 04-17-2019 04:47 PM

    Hi David, 

     

    The proxy was the issue. I was able to successfully get a response from finding and imputing the correct proxy address and port.

     

    Thank you,

     

    Dominic