Skip to content

Instantly share code, notes, and snippets.

@nelsonic
Created April 18, 2013 03:43
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save nelsonic/5409928 to your computer and use it in GitHub Desktop.
Save nelsonic/5409928 to your computer and use it in GitHub Desktop.
This is what Nimil had.
/**
* @author Nimil Christopher
* @date 12 April 2013
* @description This class has the Rest Callouts to publish an application to
* the CDN
*/
public with sharing class HTTPHelper {
public static Http http;
public static HttpRequest httpRequest;
public static HttpResponse httpResponse;
public static boolean isApexTest = false;
public static String jsonList;
@future(callout=true)
public static void sendJSONListToServer(List<String> stringList){
jsonList = 'json : ';
http = new Http();
httpRequest = new HttpRequest();
httpRequest.setEndpoint('http://fierce-springs-2179.herokuapp.com/upload');
httpRequest.setMethod('POST');
//httpRequest.setHeader('Content-Type', 'application/json');
for(String eachString : stringList){
jsonList += eachString + ',';
}
jsonList = jsonList.subString(0, jsonList.length() - 1);
httpRequest.setBody(jsonList );
System.Debug('Nimil Request Body : ' + httpRequest.getBody());
if(!isApexTest){
httpResponse = http.send(httpRequest);
System.DEBUG( 'Nimil Response : ' + httpResponse.getBody());
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment