Pivotal Tracker is an amazing agile development supporting bug/feature/story tracker system well suited for fast result oriented developments. We at Sakshum recently started using it for our development environment. Sakshum web application is hosted on Google's amazing cloud platform called Google App Engine . A natural requirement came up to be able to create stories to pivtoalTracker from google app engine when exceptional situations occur time to time. PivotalTracker's api page list only curl commands to show how a HTTP request may work to do that. We struggled quite a bit to make it work and thought to put the code here for the people who might be facing the same problem.
String pivotalUrl = "http://www.pivotaltracker.com/services/v3/projects/
String body = "
try{
URLFetchService fetchService = URLFetchServiceFactory.getURLFetchService();
HTTPRequest request = new HTTPRequest(new URL(pivotalUrl), HTTPMethod.POST, FetchOptions.Builder.withDeadline(30));
request.addHeader(new HTTPHeader("X-TrackerToken","YOUR TOKEN"));
request.addHeader(new HTTPHeader("Content-type","application/xml"));
request.setPayload(body.getBytes());
HTTPResponse response = fetchService.fetch(request);
if (response.getResponseCode() != 200) {
log.info("Could not create story as response code is:" + response.getResponseCode());
}
}catch(Exception e){
e.printStackTrace();
}
Make sure to have the TEAM MEMBER NAME a valid team member in the pivotal tracker else this wont work at all.
PivotalTracker api page for reference is here
No comments:
Post a Comment