Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
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