Advertisement
Guest User

Untitled

a guest
Dec 18th, 2014
144
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.10 KB | None | 0 0
  1. @RestResource(urlMapping='/jde_integration')
  2. global class JdeIntegration {
  3. @HttpPost
  4. global static void doPost() {
  5. String req = RestContext.request.requestBody.toString();
  6. System.debug('Req: '+req);
  7.  
  8. // Data in format 'Sl.no Name Date City 1 Testfile 25.10.2014 Hyderabad'
  9. // Want to split on whitespace, at most 8 substrings (city might have spaces)
  10. String[] params = req.split('\s', 8);
  11.  
  12. String name = params[5];
  13. String datt = params[6]; // date is a reserved word!
  14. String city = params[7];
  15.  
  16. System.debug('Got name: '+name+', date: '+datt+', city:'+city);
  17.  
  18. // Now you can insert a record, or do whatever you need to
  19. }
  20. }
  21.  
  22. $ curl -v -H 'Content-Type: text/plain' -H 'Authorization: Bearer ACCESS_TOKEN'
  23. -d 'Sl.no Name Date City 1 Testfile 25.10.2014 Hyderabad'
  24. https://na1.salesforce.com/services/apexrest/jde_integration
  25.  
  26. 09:14:41.127 (127782275)|USER_DEBUG|[7]|DEBUG|Req: Sl.no Name Date City 1 Testfile 25.10.2014 Hyderabad
  27. 09:14:41.139 (139188394)|USER_DEBUG|[17]|DEBUG|Got name: Testfile, date: 25.10.2014, city:Hyderabad
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement