RESTful API in Salesforce: The Complete Guide
Think of a REST API as the digital waiter in a restaurant. You, the Client don't just walk into the kitchen and grab what you want; instead, you place a formal HTTP Request through a standardized menu. This request tells the Server exactly what you need using a specific Endpoint and an HTTP Method like GET, POST or DELETE . Make API Callout In Salesforce public static void callAPI() { // Define the URL before using it String url = 'https://www.themealdb.com/api/json/v1/1/search.php?s=pizza'; // Instantiate a new Http object Http h = new Http(); // Instantiate a new HTTP request, specify the method (GET) as well as the endpoint HttpRequest req = new HttpRequest(); req.setEndpoint(url); // Set the URL endpoint req.setMethod('GET'); // Set the HTTP method // Set headers correctly using separate setHeader calls // req.setHeader('X-Key', 'Your API-Key'); // Send the request and get res...