{"id":1722,"date":"2026-09-29T09:00:00","date_gmt":"2026-09-29T03:30:00","guid":{"rendered":"https:\/\/swapnilzambare.com\/blog\/apex-rest-callouts-httprequest\/"},"modified":"2026-11-15T11:31:54","modified_gmt":"2026-11-15T06:01:54","slug":"apex-rest-callouts-httprequest","status":"publish","type":"post","link":"https:\/\/swapnilzambare.com\/blog\/apex-rest-callouts-httprequest\/","title":{"rendered":"Apex REST Callouts: Call External APIs with HttpRequest"},"content":{"rendered":"\n<p class=\"wp-block-paragraph\">Apex REST Callouts let your Apex code call an outside web service, send JSON and read the reply, all inside Salesforce. You use three classes: Http, HttpRequest and HttpResponse. Once you know them, you can connect Salesforce to payment gateways, shipping services, learning platforms and almost any modern API.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">In this post, you will build GET and POST callouts, read JSON responses, call out safely from triggers, and stay inside the callout limits. It builds on <a href=\"https:\/\/swapnilzambare.com\/blog\/salesforce-rest-api-postman\/\">the Salesforce REST API with Postman<\/a>, <a href=\"https:\/\/swapnilzambare.com\/blog\/queueable-apex-chaining-finalizers\/\">Queueable Apex<\/a> and <a href=\"https:\/\/swapnilzambare.com\/blog\/apex-governor-limits-explained\/\">Apex governor limits<\/a>.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">What are Apex REST Callouts?<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">Apex REST Callouts are HTTP requests that Apex sends to an external endpoint. You build an HttpRequest with a URL, a method, headers and a body. Then Http.send() sends it and returns an HttpResponse with a status code and body.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Think of sending a letter through a courier. HttpRequest is the envelope with the address and the letter inside. Http is the courier who carries it. HttpResponse is the reply letter that comes back, with a stamp that says whether things went well.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Why Apex REST Callouts Matter<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">Many business steps need data that lives outside Salesforce. Here is why Apex REST Callouts matter at Bright Path Tutors.<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>First, the PayQuick gateway confirms payments for enrolments.<\/li>\n\n<li>Also, the LearnHub platform creates a student account for each new learner.<\/li>\n\n<li>Next, a currency service converts fees for overseas students.<\/li>\n\n<li>Callouts let Apex add logic, such as retries and mapping, that Flow cannot easily do.<\/li>\n\n<li>Finally, the same skills apply to every REST service you meet.<\/li>\n<\/ul>\n\n\n\n<p class=\"wp-block-paragraph\">So callouts are one of the most used skills in integration work.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">How Apex REST Callouts Work<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">Apex REST Callouts follow a fixed sequence. First, Salesforce must trust the endpoint, through a Named Credential or a Remote Site Setting. Next, your code creates an HttpRequest and sets the endpoint, method, headers, body and timeout. Then Http.send() sends the request and waits for the reply. After that, the code checks the status code on the HttpResponse. Finally, it reads the body, often with JSON.deserialize, and updates records.<\/p>\n\n\n<figure class=\"wp-block-image aligncenter size-large\"><a href=\"https:\/\/swapnilzambare.com\/blog\/wp-content\/uploads\/2026\/11\/apex-rest-callouts-httprequest-diagram-1.png\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"640\" src=\"https:\/\/swapnilzambare.com\/blog\/wp-content\/uploads\/2026\/11\/apex-rest-callouts-httprequest-diagram-1-1024x640.png\" alt=\"Apex REST Callouts diagram showing trust, build, send, check and use\" class=\"wp-image-1720\" srcset=\"https:\/\/swapnilzambare.com\/blog\/wp-content\/uploads\/2026\/11\/apex-rest-callouts-httprequest-diagram-1-1024x640.png 1024w, https:\/\/swapnilzambare.com\/blog\/wp-content\/uploads\/2026\/11\/apex-rest-callouts-httprequest-diagram-1-300x188.png 300w, https:\/\/swapnilzambare.com\/blog\/wp-content\/uploads\/2026\/11\/apex-rest-callouts-httprequest-diagram-1-768x480.png 768w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/a><figcaption class=\"wp-element-caption\">How an Apex callout goes out and comes back.<\/figcaption><\/figure>\n\n\n<h3 class=\"wp-block-heading\">Http, HttpRequest and HttpResponse<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">Http sends requests. HttpRequest holds what you send, and HttpResponse holds what comes back, through getStatusCode() and getBody().<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Endpoint Trust<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">Salesforce blocks unknown endpoints. So you add a Named Credential, which is the recommended way, or an older Remote Site Setting.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Headers and Body<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">Use setHeader for values like Content-Type: application\/json. Then use setBody with a JSON string for POST, PUT and PATCH.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Timeouts<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">The default timeout is 10 seconds. You can raise it with setTimeout up to 120,000 milliseconds, but shorter is usually better.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Callouts and Triggers<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">Triggers cannot call out directly, because the user&#8217;s transaction must not wait on outside systems. So a trigger enqueues a Queueable or calls a future method with callout=true.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Callout Limits at a Glance<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">The table below lists the limits that matter most for Apex REST Callouts.<\/p>\n\n\n\n<figure class=\"wp-block-table\"><table><thead><tr><th>Limit<\/th><th>Value<\/th><\/tr><\/thead><tbody><tr><td>Callouts per transaction<\/td><td>100<\/td><\/tr><tr><td>Cumulative callout timeout per transaction<\/td><td>120 seconds<\/td><\/tr><tr><td>Default timeout per callout<\/td><td>10 seconds<\/td><\/tr><tr><td>Request or response size, synchronous<\/td><td>6 MB<\/td><\/tr><tr><td>Request or response size, asynchronous<\/td><td>12 MB<\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<h2 class=\"wp-block-heading\">Synchronous Callout vs Asynchronous Callout<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">The table below compares callouts that run now with callouts that run later.<\/p>\n\n\n\n<figure class=\"wp-block-table\"><table><thead><tr><th>Feature<\/th><th>Synchronous callout<\/th><th>Asynchronous callout<\/th><\/tr><\/thead><tbody><tr><td>Runs from<\/td><td>Controllers, LWC Apex, buttons<\/td><td>Queueable, future, batch<\/td><\/tr><tr><td>User waits<\/td><td>Yes<\/td><td>No<\/td><\/tr><tr><td>Allowed from triggers<\/td><td>No<\/td><td>Yes<\/td><\/tr><tr><td>Size limit<\/td><td>6 MB<\/td><td>12 MB<\/td><\/tr><tr><td>Best for<\/td><td>Quick lookups the user needs<\/td><td>Sync work after a save<\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\">When to use which follows the user. Call out synchronously only when the user needs the answer now. Otherwise, move the callout to async Apex.<\/p>\n\n\n<figure class=\"wp-block-image aligncenter size-large\"><a href=\"https:\/\/swapnilzambare.com\/blog\/wp-content\/uploads\/2026\/11\/apex-rest-callouts-httprequest-diagram-2.png\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"640\" src=\"https:\/\/swapnilzambare.com\/blog\/wp-content\/uploads\/2026\/11\/apex-rest-callouts-httprequest-diagram-2-1024x640.png\" alt=\"Apex REST Callouts diagram comparing synchronous and asynchronous callouts\" class=\"wp-image-1721\" srcset=\"https:\/\/swapnilzambare.com\/blog\/wp-content\/uploads\/2026\/11\/apex-rest-callouts-httprequest-diagram-2-1024x640.png 1024w, https:\/\/swapnilzambare.com\/blog\/wp-content\/uploads\/2026\/11\/apex-rest-callouts-httprequest-diagram-2-300x188.png 300w, https:\/\/swapnilzambare.com\/blog\/wp-content\/uploads\/2026\/11\/apex-rest-callouts-httprequest-diagram-2-768x480.png 768w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/a><figcaption class=\"wp-element-caption\">Synchronous vs asynchronous callouts.<\/figcaption><\/figure>\n\n\n<h2 class=\"wp-block-heading\">A Real Apex REST Callouts Example<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">Let&#8217;s build Apex REST Callouts at Bright Path Tutors. When a student enrols, Salesforce creates their account in LearnHub and saves the returned LearnHub Id.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Step 1: A Reusable Callout Service<\/h3>\n\n\n\n<pre class=\"wp-block-code\"><code>public with sharing class LearnHubService {\n    public class StudentResponse {\n        public String id;\n        public String status;\n    }\n\n    public static StudentResponse createStudent(String name, String email) {\n        HttpRequest req = new HttpRequest();\n        req.setEndpoint('callout:LearnHub\/v1\/students');   \/\/ Named Credential\n        req.setMethod('POST');\n        req.setHeader('Content-Type', 'application\/json');\n        req.setBody(JSON.serialize(new Map&lt;String, Object&gt;{ 'name' =&gt; name, 'email' =&gt; email }));\n        req.setTimeout(15000);\n\n        HttpResponse res = new Http().send(req);\n        if (res.getStatusCode() != 201) {\n            throw new CalloutException('LearnHub error ' + res.getStatusCode() + ': ' + res.getBody());\n        }\n        return (StudentResponse) JSON.deserialize(res.getBody(), StudentResponse.class);\n    }\n}<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">The service builds a POST with a JSON body and a 15-second timeout. Then it checks for 201 Created and turns the JSON reply into a small Apex class.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Step 2: Call It from a Queueable<\/h3>\n\n\n\n<pre class=\"wp-block-code\"><code>public with sharing class LearnHubSyncJob implements Queueable, Database.AllowsCallouts {\n    private Id enrolmentId;\n    public LearnHubSyncJob(Id enrolmentId) { this.enrolmentId = enrolmentId; }\n\n    public void execute(QueueableContext ctx) {\n        Enrolment__c e = [SELECT Id, Student__r.Name, Student__r.Email\n                          FROM Enrolment__c WHERE Id = :enrolmentId WITH USER_MODE];\n        LearnHubService.StudentResponse r =\n            LearnHubService.createStudent(e.Student__r.Name, e.Student__r.Email);\n        e.LearnHub_Id__c = r.id;\n        update as user e;\n    }\n}<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">The trigger enqueues this job, so the save never waits. Database.AllowsCallouts permits the callout, and the job saves LearnHub&#8217;s Id after the reply. For many enrolments, pass a list of Ids instead of one.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Step 3: See the Result<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">Here is the debug log and the updated record after one enrolment.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>CALLOUT_REQUEST  POST callout:LearnHub\/v1\/students\nCALLOUT_RESPONSE 201 {\"id\":\"LH-20931\",\"status\":\"active\"}\nEnrolment E-0043: LearnHub_Id__c = LH-20931<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">The student&#8217;s LearnHub account exists, and Salesforce keeps its Id for later calls.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Apex REST Callouts and Uncommitted Work<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">You cannot call out after DML in the same transaction. Otherwise, Salesforce throws &#8220;You have uncommitted work pending&#8221;. So make callouts first and DML after, or move the callout to a separate async job.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Common Mistakes with Apex REST Callouts<\/h2>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Calling out directly from a trigger.<\/li>\n\n<li>Hard-coding URLs and API keys instead of using Named Credentials.<\/li>\n\n<li>Doing DML before a callout in the same transaction.<\/li>\n\n<li>Ignoring non-200 status codes and saving bad data.<\/li>\n\n<li>Forgetting tests, which need a mock because tests cannot call real endpoints.<\/li>\n<\/ul>\n\n\n\n<h2 class=\"wp-block-heading\">Best Practices for Apex REST Callouts<\/h2>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Keep callout code in one service class per external system.<\/li>\n\n<li>Use Named Credentials for endpoints and authentication.<\/li>\n\n<li>Set a sensible timeout and handle every error status.<\/li>\n\n<li>Run callouts in async Apex after a save.<\/li>\n\n<li>Test with <a href=\"https:\/\/swapnilzambare.com\/blog\/apex-callout-mocks-httpcalloutmock\/\">HttpCalloutMock<\/a> for success and failure.<\/li>\n\n<li>Log failures so support can retry them.<\/li>\n<\/ul>\n\n\n\n<h2 class=\"wp-block-heading\">Practice Task<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">Add a GET method to LearnHubService that reads a student&#8217;s progress by LearnHub Id. Hint: build the URL with the Id, use GET, and deserialize into a new inner class.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Most Asked Interview Questions on Apex REST Callouts<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">Callout questions appear in nearly every developer interview. Here are the 22 questions asked most about Apex REST Callouts.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Basic Questions on Apex REST Callouts<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Q1: What is an Apex callout?<\/strong><\/p>\n\n\n\n<p class=\"wp-block-paragraph\">A call from Apex to an external web service over HTTP or SOAP.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Q2: Which classes do you use for REST callouts?<\/strong><\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Http, HttpRequest and HttpResponse.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Q3: Why does Salesforce need a Remote Site Setting or Named Credential?<\/strong><\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Because it blocks unknown endpoints, so you must declare the ones you trust.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Q4: How do you read the response?<\/strong><\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Call getStatusCode() for the status and getBody() for the content.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Q5: What is the default callout timeout?<\/strong><\/p>\n\n\n\n<p class=\"wp-block-paragraph\">10 seconds, and you can set up to 120 seconds with setTimeout.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Q6: How many callouts can one transaction make?<\/strong><\/p>\n\n\n\n<p class=\"wp-block-paragraph\">100 callouts, with a 120-second cumulative timeout.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Q7: How do you send JSON?<\/strong><\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Set the Content-Type header and pass JSON.serialize output to setBody.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Code and Scenario Questions on Apex REST Callouts<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Q8: How do you call out from a trigger?<\/strong><\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Enqueue a Queueable that implements Database.AllowsCallouts, or call a future method with callout=true.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Q9: What causes &#8220;You have uncommitted work pending&#8221;?<\/strong><\/p>\n\n\n\n<p class=\"wp-block-paragraph\">DML ran before the callout in the same transaction, so reorder the code or go async.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Q10: How do you test a callout?<\/strong><\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Implement HttpCalloutMock and register it with Test.setMock before calling the code.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Q11: How do you handle a 500 error from the service?<\/strong><\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Check the status code, log the body, and retry later or show a clear message.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Q12: How do you parse a JSON reply into Apex?<\/strong><\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Use JSON.deserialize with a matching Apex class, or deserializeUntyped for flexible data.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Q13: How do you call out from Batch Apex?<\/strong><\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Implement Database.AllowsCallouts on the batch class and keep calls within limits per execute.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Q14: Can an LWC trigger a callout?<\/strong><\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Yes, so it calls an @AuraEnabled Apex method that makes a synchronous callout.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Advanced Questions on Apex REST Callouts<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Q15: Why prefer Named Credentials over Remote Site Settings?<\/strong><\/p>\n\n\n\n<p class=\"wp-block-paragraph\">They store the URL and authentication together, so code holds no secrets.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Q16: How do you call out for 1,000 records?<\/strong><\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Batch the work, group records per call where the API allows, and use Batch Apex or chained Queueables.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Q17: What is a Continuation?<\/strong><\/p>\n\n\n\n<p class=\"wp-block-paragraph\">An async callout pattern for long requests started from Visualforce, Aura or LWC, so server threads are not held.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Q18: How do you add retries safely?<\/strong><\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Use a Queueable finalizer or scheduled retry, with a counter so it stops after a few tries.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Q19: What is the response size limit?<\/strong><\/p>\n\n\n\n<p class=\"wp-block-paragraph\">6 MB in synchronous Apex and 12 MB in asynchronous Apex.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Q20: How do you make callouts idempotent?<\/strong><\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Send a unique request key, so the service ignores repeated requests.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Q21: How do you keep callout code testable?<\/strong><\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Put all HTTP logic in one service class and mock it with HttpCalloutMock.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Q22: When should Flow make the callout instead of Apex?<\/strong><\/p>\n\n\n\n<p class=\"wp-block-paragraph\">When the call is simple and admins own the process, Flow HTTP callouts are enough.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Official Resources<\/h2>\n\n\n\n<ul class=\"wp-block-list\">\n<li><a href=\"https:\/\/developer.salesforce.com\/docs\/platform\/apex-dev\/references\/apex-dev\/apex-callouts-http.html\" target=\"_blank\" rel=\"noopener noreferrer\">Invoking HTTP Callouts (Apex Developer Guide)<\/a><\/li>\n\n<li><a href=\"https:\/\/developer.salesforce.com\/docs\/platform\/apex-dev\/references\/apex-dev\/apex-callouts-timeouts.html\" target=\"_blank\" rel=\"noopener noreferrer\">Callout Limits and Limitations (Apex Developer Guide)<\/a><\/li>\n<\/ul>\n\n\n\n<h2 class=\"wp-block-heading\">Quick Recap<\/h2>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Apex REST Callouts use Http, HttpRequest and HttpResponse.<\/li>\n\n<li>Endpoints must be trusted through a Named Credential or Remote Site Setting.<\/li>\n\n<li>Check the status code before trusting the body.<\/li>\n\n<li>Call out from async Apex after a save, never directly from triggers.<\/li>\n\n<li>Stay within 100 callouts and 120 seconds per transaction.<\/li>\n<\/ul>\n\n\n\n<h2 class=\"wp-block-heading\">What&#8217;s Next?<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">Hard-coded URLs and keys are a security risk. Next, read our guide to <a href=\"https:\/\/swapnilzambare.com\/blog\/named-credentials-in-apex-callouts\/\">Named Credentials in Apex<\/a>.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Apex REST Callouts let your Apex code call an outside web service, send JSON and read the reply, all inside Salesforce. You use three&hellip;<\/p>\n","protected":false},"author":1,"featured_media":1719,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_swapz_level":"","_swapz_series_part":0,"_swapz_hide_toc":false,"_swapz_hide_featured":false,"_swapz_description":"","footnotes":""},"categories":[246,8,96],"tags":[98,81,26],"swapz_series":[],"class_list":["post-1722","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-integration-apis","category-salesforce","category-salesforce-developer","tag-apex","tag-integration","tag-intermediate"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v28.9 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>Apex REST Callouts: HttpRequest Made Simple<\/title>\n<meta name=\"description\" content=\"Apex REST Callouts explained simply: Http, HttpRequest, HttpResponse, GET and POST, JSON, limits, callouts from triggers, testing and 22 interview Q&amp;A.\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/swapnilzambare.com\/blog\/apex-rest-callouts-httprequest\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Apex REST Callouts: HttpRequest Made Simple\" \/>\n<meta property=\"og:description\" content=\"Apex REST Callouts explained simply: Http, HttpRequest, HttpResponse, GET and POST, JSON, limits, callouts from triggers, testing and 22 interview Q&amp;A.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/swapnilzambare.com\/blog\/apex-rest-callouts-httprequest\/\" \/>\n<meta property=\"og:site_name\" content=\"Swapnil Zambare - Blog\" \/>\n<meta property=\"article:published_time\" content=\"2026-09-29T03:30:00+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2026-11-15T06:01:54+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/swapnilzambare.com\/blog\/wp-content\/uploads\/2026\/11\/apex-rest-callouts-httprequest-featured.png\" \/>\n\t<meta property=\"og:image:width\" content=\"2400\" \/>\n\t<meta property=\"og:image:height\" content=\"1260\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/png\" \/>\n<meta name=\"author\" content=\"Swapnil Zambare\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Swapnil Zambare\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"8 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\\\/\\\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\\\/\\\/swapnilzambare.com\\\/blog\\\/apex-rest-callouts-httprequest\\\/#article\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/swapnilzambare.com\\\/blog\\\/apex-rest-callouts-httprequest\\\/\"},\"author\":{\"name\":\"Swapnil Zambare\",\"@id\":\"https:\\\/\\\/swapnilzambare.com\\\/blog\\\/#\\\/schema\\\/person\\\/10b09224c8bcc562716e86789427592a\"},\"headline\":\"Apex REST Callouts: Call External APIs with HttpRequest\",\"datePublished\":\"2026-09-29T03:30:00+00:00\",\"dateModified\":\"2026-11-15T06:01:54+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\\\/\\\/swapnilzambare.com\\\/blog\\\/apex-rest-callouts-httprequest\\\/\"},\"wordCount\":1515,\"publisher\":{\"@id\":\"https:\\\/\\\/swapnilzambare.com\\\/blog\\\/#organization\"},\"image\":{\"@id\":\"https:\\\/\\\/swapnilzambare.com\\\/blog\\\/apex-rest-callouts-httprequest\\\/#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/swapnilzambare.com\\\/blog\\\/wp-content\\\/uploads\\\/2026\\\/11\\\/apex-rest-callouts-httprequest-featured.png\",\"keywords\":[\"Apex\",\"Integration\",\"Intermediate\"],\"articleSection\":[\"Integration and APIs\",\"Salesforce\",\"Salesforce Developer\"],\"inLanguage\":\"en-US\"},{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/swapnilzambare.com\\\/blog\\\/apex-rest-callouts-httprequest\\\/\",\"url\":\"https:\\\/\\\/swapnilzambare.com\\\/blog\\\/apex-rest-callouts-httprequest\\\/\",\"name\":\"Apex REST Callouts: HttpRequest Made Simple\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/swapnilzambare.com\\\/blog\\\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\\\/\\\/swapnilzambare.com\\\/blog\\\/apex-rest-callouts-httprequest\\\/#primaryimage\"},\"image\":{\"@id\":\"https:\\\/\\\/swapnilzambare.com\\\/blog\\\/apex-rest-callouts-httprequest\\\/#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/swapnilzambare.com\\\/blog\\\/wp-content\\\/uploads\\\/2026\\\/11\\\/apex-rest-callouts-httprequest-featured.png\",\"datePublished\":\"2026-09-29T03:30:00+00:00\",\"dateModified\":\"2026-11-15T06:01:54+00:00\",\"description\":\"Apex REST Callouts explained simply: Http, HttpRequest, HttpResponse, GET and POST, JSON, limits, callouts from triggers, testing and 22 interview Q&A.\",\"breadcrumb\":{\"@id\":\"https:\\\/\\\/swapnilzambare.com\\\/blog\\\/apex-rest-callouts-httprequest\\\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\\\/\\\/swapnilzambare.com\\\/blog\\\/apex-rest-callouts-httprequest\\\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/swapnilzambare.com\\\/blog\\\/apex-rest-callouts-httprequest\\\/#primaryimage\",\"url\":\"https:\\\/\\\/swapnilzambare.com\\\/blog\\\/wp-content\\\/uploads\\\/2026\\\/11\\\/apex-rest-callouts-httprequest-featured.png\",\"contentUrl\":\"https:\\\/\\\/swapnilzambare.com\\\/blog\\\/wp-content\\\/uploads\\\/2026\\\/11\\\/apex-rest-callouts-httprequest-featured.png\",\"width\":2400,\"height\":1260,\"caption\":\"Apex REST Callouts featured image: title card with an integration code example\"},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/swapnilzambare.com\\\/blog\\\/apex-rest-callouts-httprequest\\\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\\\/\\\/swapnilzambare.com\\\/blog\\\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Apex REST Callouts: Call External APIs with HttpRequest\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\\\/\\\/swapnilzambare.com\\\/blog\\\/#website\",\"url\":\"https:\\\/\\\/swapnilzambare.com\\\/blog\\\/\",\"name\":\"Swapnil Zambare - Blog\",\"description\":\"Salesforce &amp; Tech Guides\",\"publisher\":{\"@id\":\"https:\\\/\\\/swapnilzambare.com\\\/blog\\\/#organization\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\\\/\\\/swapnilzambare.com\\\/blog\\\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Organization\",\"@id\":\"https:\\\/\\\/swapnilzambare.com\\\/blog\\\/#organization\",\"name\":\"Swapnil Zambare - Blog\",\"url\":\"https:\\\/\\\/swapnilzambare.com\\\/blog\\\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/swapnilzambare.com\\\/blog\\\/#\\\/schema\\\/logo\\\/image\\\/\",\"url\":\"https:\\\/\\\/swapnilzambare.com\\\/blog\\\/wp-content\\\/uploads\\\/2026\\\/09\\\/site-icon-512.png\",\"contentUrl\":\"https:\\\/\\\/swapnilzambare.com\\\/blog\\\/wp-content\\\/uploads\\\/2026\\\/09\\\/site-icon-512.png\",\"width\":512,\"height\":512,\"caption\":\"Swapnil Zambare - Blog\"},\"image\":{\"@id\":\"https:\\\/\\\/swapnilzambare.com\\\/blog\\\/#\\\/schema\\\/logo\\\/image\\\/\"},\"sameAs\":[\"https:\\\/\\\/www.linkedin.com\\\/in\\\/theSwapnilZambare\"]},{\"@type\":\"Person\",\"@id\":\"https:\\\/\\\/swapnilzambare.com\\\/blog\\\/#\\\/schema\\\/person\\\/10b09224c8bcc562716e86789427592a\",\"name\":\"Swapnil Zambare\",\"sameAs\":[\"https:\\\/\\\/swapnilzambare.com\\\/blog\"],\"url\":\"https:\\\/\\\/swapnilzambare.com\\\/blog\\\/author\\\/swapnil-zambare\\\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Apex REST Callouts: HttpRequest Made Simple","description":"Apex REST Callouts explained simply: Http, HttpRequest, HttpResponse, GET and POST, JSON, limits, callouts from triggers, testing and 22 interview Q&A.","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/swapnilzambare.com\/blog\/apex-rest-callouts-httprequest\/","og_locale":"en_US","og_type":"article","og_title":"Apex REST Callouts: HttpRequest Made Simple","og_description":"Apex REST Callouts explained simply: Http, HttpRequest, HttpResponse, GET and POST, JSON, limits, callouts from triggers, testing and 22 interview Q&A.","og_url":"https:\/\/swapnilzambare.com\/blog\/apex-rest-callouts-httprequest\/","og_site_name":"Swapnil Zambare - Blog","article_published_time":"2026-09-29T03:30:00+00:00","article_modified_time":"2026-11-15T06:01:54+00:00","og_image":[{"width":2400,"height":1260,"url":"https:\/\/swapnilzambare.com\/blog\/wp-content\/uploads\/2026\/11\/apex-rest-callouts-httprequest-featured.png","type":"image\/png"}],"author":"Swapnil Zambare","twitter_card":"summary_large_image","twitter_misc":{"Written by":"Swapnil Zambare","Est. reading time":"8 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/swapnilzambare.com\/blog\/apex-rest-callouts-httprequest\/#article","isPartOf":{"@id":"https:\/\/swapnilzambare.com\/blog\/apex-rest-callouts-httprequest\/"},"author":{"name":"Swapnil Zambare","@id":"https:\/\/swapnilzambare.com\/blog\/#\/schema\/person\/10b09224c8bcc562716e86789427592a"},"headline":"Apex REST Callouts: Call External APIs with HttpRequest","datePublished":"2026-09-29T03:30:00+00:00","dateModified":"2026-11-15T06:01:54+00:00","mainEntityOfPage":{"@id":"https:\/\/swapnilzambare.com\/blog\/apex-rest-callouts-httprequest\/"},"wordCount":1515,"publisher":{"@id":"https:\/\/swapnilzambare.com\/blog\/#organization"},"image":{"@id":"https:\/\/swapnilzambare.com\/blog\/apex-rest-callouts-httprequest\/#primaryimage"},"thumbnailUrl":"https:\/\/swapnilzambare.com\/blog\/wp-content\/uploads\/2026\/11\/apex-rest-callouts-httprequest-featured.png","keywords":["Apex","Integration","Intermediate"],"articleSection":["Integration and APIs","Salesforce","Salesforce Developer"],"inLanguage":"en-US"},{"@type":"WebPage","@id":"https:\/\/swapnilzambare.com\/blog\/apex-rest-callouts-httprequest\/","url":"https:\/\/swapnilzambare.com\/blog\/apex-rest-callouts-httprequest\/","name":"Apex REST Callouts: HttpRequest Made Simple","isPartOf":{"@id":"https:\/\/swapnilzambare.com\/blog\/#website"},"primaryImageOfPage":{"@id":"https:\/\/swapnilzambare.com\/blog\/apex-rest-callouts-httprequest\/#primaryimage"},"image":{"@id":"https:\/\/swapnilzambare.com\/blog\/apex-rest-callouts-httprequest\/#primaryimage"},"thumbnailUrl":"https:\/\/swapnilzambare.com\/blog\/wp-content\/uploads\/2026\/11\/apex-rest-callouts-httprequest-featured.png","datePublished":"2026-09-29T03:30:00+00:00","dateModified":"2026-11-15T06:01:54+00:00","description":"Apex REST Callouts explained simply: Http, HttpRequest, HttpResponse, GET and POST, JSON, limits, callouts from triggers, testing and 22 interview Q&A.","breadcrumb":{"@id":"https:\/\/swapnilzambare.com\/blog\/apex-rest-callouts-httprequest\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/swapnilzambare.com\/blog\/apex-rest-callouts-httprequest\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/swapnilzambare.com\/blog\/apex-rest-callouts-httprequest\/#primaryimage","url":"https:\/\/swapnilzambare.com\/blog\/wp-content\/uploads\/2026\/11\/apex-rest-callouts-httprequest-featured.png","contentUrl":"https:\/\/swapnilzambare.com\/blog\/wp-content\/uploads\/2026\/11\/apex-rest-callouts-httprequest-featured.png","width":2400,"height":1260,"caption":"Apex REST Callouts featured image: title card with an integration code example"},{"@type":"BreadcrumbList","@id":"https:\/\/swapnilzambare.com\/blog\/apex-rest-callouts-httprequest\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/swapnilzambare.com\/blog\/"},{"@type":"ListItem","position":2,"name":"Apex REST Callouts: Call External APIs with HttpRequest"}]},{"@type":"WebSite","@id":"https:\/\/swapnilzambare.com\/blog\/#website","url":"https:\/\/swapnilzambare.com\/blog\/","name":"Swapnil Zambare - Blog","description":"Salesforce &amp; Tech Guides","publisher":{"@id":"https:\/\/swapnilzambare.com\/blog\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/swapnilzambare.com\/blog\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Organization","@id":"https:\/\/swapnilzambare.com\/blog\/#organization","name":"Swapnil Zambare - Blog","url":"https:\/\/swapnilzambare.com\/blog\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/swapnilzambare.com\/blog\/#\/schema\/logo\/image\/","url":"https:\/\/swapnilzambare.com\/blog\/wp-content\/uploads\/2026\/09\/site-icon-512.png","contentUrl":"https:\/\/swapnilzambare.com\/blog\/wp-content\/uploads\/2026\/09\/site-icon-512.png","width":512,"height":512,"caption":"Swapnil Zambare - Blog"},"image":{"@id":"https:\/\/swapnilzambare.com\/blog\/#\/schema\/logo\/image\/"},"sameAs":["https:\/\/www.linkedin.com\/in\/theSwapnilZambare"]},{"@type":"Person","@id":"https:\/\/swapnilzambare.com\/blog\/#\/schema\/person\/10b09224c8bcc562716e86789427592a","name":"Swapnil Zambare","sameAs":["https:\/\/swapnilzambare.com\/blog"],"url":"https:\/\/swapnilzambare.com\/blog\/author\/swapnil-zambare\/"}]}},"_links":{"self":[{"href":"https:\/\/swapnilzambare.com\/blog\/wp-json\/wp\/v2\/posts\/1722","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/swapnilzambare.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/swapnilzambare.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/swapnilzambare.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/swapnilzambare.com\/blog\/wp-json\/wp\/v2\/comments?post=1722"}],"version-history":[{"count":1,"href":"https:\/\/swapnilzambare.com\/blog\/wp-json\/wp\/v2\/posts\/1722\/revisions"}],"predecessor-version":[{"id":2332,"href":"https:\/\/swapnilzambare.com\/blog\/wp-json\/wp\/v2\/posts\/1722\/revisions\/2332"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/swapnilzambare.com\/blog\/wp-json\/wp\/v2\/media\/1719"}],"wp:attachment":[{"href":"https:\/\/swapnilzambare.com\/blog\/wp-json\/wp\/v2\/media?parent=1722"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/swapnilzambare.com\/blog\/wp-json\/wp\/v2\/categories?post=1722"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/swapnilzambare.com\/blog\/wp-json\/wp\/v2\/tags?post=1722"},{"taxonomy":"swapz_series","embeddable":true,"href":"https:\/\/swapnilzambare.com\/blog\/wp-json\/wp\/v2\/swapz_series?post=1722"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}