Skip to content

Instantly share code, notes, and snippets.

@mpassovoy
Created February 11, 2019 21:06
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 mpassovoy/9b66d3a114473064ae2e549159e712c9 to your computer and use it in GitHub Desktop.
Save mpassovoy/9b66d3a114473064ae2e549159e712c9 to your computer and use it in GitHub Desktop.
Product JSON and Callout Sample
List prods = new List();
prods.add('productId1');
prods.add('productId2');
prods.add('productId3');
prods.add('productIdN');
//make sure to change the name of the class to wherever you send data to the generic JSON from
String jsonString = Product_RESTClass.setupJson(prods);
HttpRequest req = new HttpRequest();
String callout = 'callout:' + Named_Credential + /services/apexrest/PRODUCT_REST_ENDPOINT';
req.setEndpoint(callout);
req.setBody('json=' + jsonString);
req.setMethod('POST');
Http http = new Http();
HTTPResponse res = http.send(req);
System.debug(res.getBody());
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment