Access the CA Agile Central Web Services API On-Premises instance
search cancel

Access the CA Agile Central Web Services API On-Premises instance

book

Article ID: 57566

calendar_today

Updated On:

Products

CA Agile Central On Premise (Rally) CA Agile Central SaaS (Rally)

Issue/Introduction

When a user of CA Agile Central on-premises instance clicks on Help link and follows the link to Web Services API, the user is taken to CA Agile Central on-demand (SaaS) login page:

https://rally1.rallydev.com/slm/login.op

Environment

Release:
Component: ACPREM

Resolution

To access Web Services interactive documentation and object model specific to your on-premises workspace, replace <YOUR_HOST_IP_ADDRESS> with your Rally on-premises server.,
following this format:

https://<YOUR_HOST_IP_ADDRESS>/slm/doc/webservice/

Using CA Agile Central REST Toolkit for Ruby:

require 'rally_api'

#Setup custom app information
headers = RallyAPI::CustomHttpHeader.new()
headers.name = "My Utility"
headers.vendor = "My RallyLab"
headers.version = "1.0"

# Connection to CA Agile Central
config = {:base_url => "https://<YOUR_HOST_IP_ADDRESS>/slm"}
config[:username] = "<USERNAME>"
config[:password] = "<PASSWORD>"
config[:workspace] = "<WORKSPACE_NAME>"
config[:project] = "<PROJECT_NAME"
config[:headers] = headers #from RallyAPI::CustomHttpHeader.new()
config[:version] = "v2.0"

@rally = RallyAPI::RallyRestJson.new(config)

obj = {}
obj["user"] = {"_ref" => "https://<YOUR_HOST_IP_ADDRESS>/slm/webservice/v2.0/user/<USER_OID>"}
obj["Role"] = "Editor"
#obj["Role"] = "Viewer"
obj["Project"] = {"_ref" => "https://<YOUR_HOST_IP_ADDRESS>/slm/webservice/v2.0/project/<PROJECT OID>" }
new_projectpermission = @rally.create("projectpermission", obj)

Using Java REST Toolkit for Java:

import java.io.IOException;
import java.net.URI;
import java.net.URISyntaxException;
import com.google.gson.JsonObject;
import com.rallydev.rest.RallyRestApi;
import com.rallydev.rest.request.CreateRequest;
import com.rallydev.rest.response.CreateResponse;
import com.rallydev.rest.util.Ref;


public class CreateStoryOnPremCountBytesInString {

	public static void main(String[] args) throws URISyntaxException, IOException {
		

	       String host = "http://<YOUR_HOST_IP_ADDRESS>";   //had to use http to bypass Exception : javax.net.ssl.SSLPeerUnverifiedException: peer not authenticated
	       String username = "<USERNAME>";
	       String password = "<PASSWORD>";
	        String wsapiVersion = "v2.0";
	        String projectRef = "/project/<PROJECT_OID>";
	        String applicationName = "Example-createStory";
	        
		
        RallyRestApi restApi = new RallyRestApi(
        		new URI(host),
        		username,
        		password);
        restApi.setWsapiVersion(wsapiVersion);
        
        
        String storyName = //"................................................................................."; //your string here
        restApi.setApplicationName(applicationName);   
        byte[] utf8Bytes = storyName.getBytes("UTF-8");
        System.out.println(utf8Bytes.length); // prints "253"
        
        byte[] utf16Bytes= storyName.getBytes("UTF-16");
        System.out.println(utf16Bytes.length); // prints "328"

        byte[] utf32Bytes = storyName.getBytes("UTF-32");
        System.out.println(utf32Bytes.length); // prints "652"

        byte[] isoBytes = storyName.getBytes("ISO-8859-1");
        System.out.println(isoBytes.length); // prints "163"

        byte[] winBytes = storyName.getBytes("CP1252");
        System.out.println(winBytes.length); // prints "163"
        
        try {
            
	            System.out.println("Creating a story...");
	            JsonObject newStory = new JsonObject();
	            
	            newStory.addProperty("Name", storyName);
	            newStory.addProperty("Project", projectRef); 

	             
	            CreateRequest createRequest = new CreateRequest("hierarchicalrequirement", newStory);
	            //System.out.println(createRequest.getBody());
	            CreateResponse createResponse = restApi.create(createRequest);  
	            if (createResponse.wasSuccessful()) {
	            	
	            	System.out.println(String.format("Created %s", createResponse.getObject().get("_ref").getAsString()));          
	            	String[] warningList;
	            	warningList = createResponse.getWarnings();
	            	for (int w = 0; w < warningList.length; w++){
	            		System.out.println(warningList[w]);
	            	}
		            //Read epic story
		            String storyRef = Ref.getRelativeRef(createResponse.getObject().get("_ref").getAsString());
		            System.out.println(String.format("\nReading epic story %s...",storyRef));
		        }
		        else {
	            	String[] createErrors;
	            	createErrors = createResponse.getErrors();
	        		System.out.println("Error!");
	            	for (int i=0; i<createErrors.length;i++) {
	            		System.out.println(createErrors[i]);
	            	}
	            }
        } finally {
            //Release all resources
            restApi.close();
        }   

	} 
	
}