Skip to content

Instantly share code, notes, and snippets.

@karanrajs
Created May 28, 2016 05:51
Show Gist options
  • Save karanrajs/cd012c71470823918024405c259d0880 to your computer and use it in GitHub Desktop.
Save karanrajs/cd012c71470823918024405c259d0880 to your computer and use it in GitHub Desktop.
//Anonymous APEX REST Service that you can subscribe to with LittleBits Cloudbit
@RestResource(urlMapping='/subscriber')
global with sharing class LittleBitsSubscriber
{
@HttpPost
global static String processSubscriptionEvent()
{
String requestBody = RestContext.request.requestBody.toString();
system.debug(requestBody);
Map<String, Object> littleBitsdata = (Map<String, Object>) JSON.deserializeUntyped(requestBody);
LittleBit_Feedback__c bitsFeedback = new LittleBit_Feedback__c(Location__c =littleBitsdata.get('bit_id'), Description__c =String.valueof(littleBitsdata));
insert bitsFeedback;
return 'Success';
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment