Question

we are with a simple requirement to be able to create a story in PivotalTracker when an email goes is sent to our org id like say bugs@my-org.com

I could find couple or ruby based wrappers but nothing in java which I can run on our GAE app. Any advise if any such solution exists?

There are some api mention at https://www.pivotaltracker.com/help/api?version=v3#add_story with code in curl

curl -H "X-TrackerToken: $TOKEN" -X POST -H "Content-type: application/xml" \
    -d "<story><story_type>feature</story_type><name>Fire torpedoes</name><requested_by>James Kirk</requested_by></story>" \
    http://www.pivotaltracker.com/services/v3/projects/$PROJECT_ID/stories

not sure how do we do it in java?

Was it helpful?

Solution

You need to do two things:

  1. Receive email in GAE

  2. Make a POST request via URLFetch:

    String pivotalUrl = "http://www.pivotaltracker.com/services/v3/projects/"+projectID+"/stories"
    
    String body = "<story><story_type>feature</story_type><name>Story name</name><requested_by>James Kirk</requested_by></story>"
    
    URLFetchService fetchService = URLFetchServiceFactory.getURLFetchService();
    HTTPRequest request =  new HTTPRequest(pivotalUrl, HTTPMethod.POST, FetchOptions.Builder.withDeadline(30));
    request.addHeader(new HTTPHeader("X-TrackerToken","putTokenHere"));
    request.addHeader(new HTTPHeader("Content-type","application/xml"));
    
    HTTPResponse response = fetchService.fetch(request);
    if (response.getResponseCode() != 200) {
        // something went wrong
    }
    
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top