diff --git a/src/main/java/com/rallydev/lookback/LookbackApi.java b/src/main/java/com/rallydev/lookback/LookbackApi.java index ac0cbe6..217d17a 100644 --- a/src/main/java/com/rallydev/lookback/LookbackApi.java +++ b/src/main/java/com/rallydev/lookback/LookbackApi.java @@ -50,6 +50,7 @@ public class LookbackApi { protected String proxyUserName; protected String proxyPassword; protected HttpClient client; + protected String apikey; /** @@ -170,6 +171,14 @@ public LookbackApi setServer(String server) { return this; } + /** + * Set the API key to be used for authentication. If used, do not set username and password. + * @param key - The api key generated by Rally. + */ + public void setApiKey(String key) { + this.apikey = key; + } + /** * Set the proxy server you wish to communicate through. * @param server - The proxy server you wish to use, must include the protocol (e.g. http://myproxy:8080 ) @@ -248,6 +257,9 @@ private LookbackResult buildLookbackResult(HttpResponse response) throws IOExcep private HttpUriRequest createRequest(String requestJson) throws IOException { HttpPost post = new HttpPost(buildUrl()); + if (this.apikey != null) { + post.setHeader("zsessionid", this.apikey); + } post.setEntity(new StringEntity(requestJson, "UTF-8")); return post; }