Cloudstock Force.com Mini Hack #1

Hey guys, following on from Mini Hacks last week at Cloudstock, I thought I’d post the challenges here in the blog so y’all can share your solutions in comments.

If you can’t read the text on the graphic, here is what we called the Integration Hack~

Challenge: Integrate a Force.com application with a web service hosted at Heroku

Requirements:

  • This challenge requires a Force.com Developer Edition account: http://bit.ly/dfcsignup
  • Write functionality which, upon creation of a new Contact will submit the Contact’s First, Last Names and Email address to the web service at http://cs12minihack.herokuapp.com/ using the following JSON format:
    {
    “firstName”: “Marc”,
    “lastName”: “Benioff”,
    “email”: “ceo@salesforce.com”
    }

Submit Your Results:

  • Follow the directions in the reply from your web service call

That’s it! Feel free to post how you solved this and what your return result was.

tagged Bookmark the permalink. Trackbacks are closed, but you can post a comment.
  • Srinivasa Rao

    Here is the message which I got as a response of call out “ZOMG – go to Hackathon HQ with this message and see if you get a prize! :-)

    Sample Code:

    Public Class JSONChallenge{
    @future(callout=true)
    public static void parseJSONResponse() {
    Http httpProtocol = new Http();
    HttpRequest request = new HttpRequest();
    String endpoint = ‘http://cs12minihack.herokuapp.com/';
    request.setEndPoint(endpoint);
    request.setHeader(‘Content-Type’, ‘application/json’);
    request.setBody(‘{“firstName”:”Tim”,”lastName”:”Barr”,”email”:”barr_tim@grandhotels.com”}’);
    request.setMethod(‘GET’);
    HttpResponse response = httpProtocol.send(request);
    system.debug(‘$$$$$:’+response.getBody());
    }
    }

  • Srinivasa Rao

    When I use the JSON.serialize() method, it is returning the format in upper case letter (FirstName, LastName and Email)
    [{"attributes":{"type":"Contact","url":"/services/data/v24.0/sobjects/Contact/0037000000V8V35AAF"},"LastName":"Barr","FirstName":"Tim","Email":"barr_tim@grandhotels.com"}]

    but the host is expecting in camel case format (firstName, lastName and email)