Product JSON and Callout Sample
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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