Defined an Named credential to get the access token and status of the named credential is 'Authenticated' but when I do call the Apex call out it doesn't return success response. I am not sure what I am missing here?
HttpRequest req = new HttpRequest();
req.setEndpoint('callout:OKTA_Authentication');
req.setHeader('Accept', 'application/json');
req.setHeader('Content-Type','application/x-www-form-urlencoded');
req.setMethod('POST');
Http http = new Http();
HTTPResponse res = http.send(req);
System.debug(res.getBody());
Error response on calling Named credential
<!DOCTYPE html><html lang="en"><head><meta http-equiv="Content-Type" content="text/html; charset=utf-8"/><meta name="robots" content="noarchive"/><meta name="googlebot" content="noarchive"/><meta name="robots" content="noindex" />
<meta http-equiv="X-UA-Compatible" content="IE=Edge" />
<meta name="apple-mobile-web-app-capable" content="yes"><meta name="googlebot" content="noindex" />
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta name="robots" content="none" />
<link href="https://ok6static.oktacdn.com/assets/img/icons/favicons/favicon-16x16.c55b69ae49b08edc7c000d12b8e5483f.png" rel="icon" type="image/png" sizes="16x16"/><link href="https://ok6static.oktacdn.com/assets/img/icons/favicons/favicon-32x32.99bc356b6e293b927f9e3a2b69761c26.png" rel="icon" type="image/png" sizes="32x32"/><link href="https://ok6static.oktacdn.com/assets/img/icons/favicons/favicon-96x96.de98828614fa33ca04fcfaa07679f345.png" rel="icon" type="image/png" sizes="96x96"/><meta name="msapplication-TileColor" content="#ffffff">
<meta name="msapplication-TileImage" content="/img/icons/favicons/ms-icon-144x144.png">
<meta name="application-name" content="Okta"/>
<meta name="theme-color" content="#ffffff">
<meta name="msapplication-config" content="/img/icons/favicons/browserconfig.xml"/>
<title>
- Page Not Found</title>
<link href="https://ok6static.oktacdn.com/assets/css/saasure-min.b2b2ac191046797c70dcac96526d6c99.css" type="text/css" rel="stylesheet"/><link href="https://ok6static.oktacdn.com/assets/css/okta.30984382ae34d45ba5cb2e042185c723.css" type="text/css" rel="stylesheet"/><link href="https://ok6static.oktacdn.com/assets/css/sections/errors.b2abd427f382d7a7c6648d7d71a06a7f.css" type="text/css" rel="stylesheet"/><!--[if IE]><link href="https://ok6static.oktacdn.com/assets/css/ie/ie.67af4e98a9276b3eedc54211bb17ace8.css" type="text/css" rel="stylesheet"/><![endif]-->
<!--[if gte IE 9]><link href="https://ok6static.oktacdn.com/assets/css/ie/ie9.e98bfbcf44b614a6d63c04328b8b7b5e.css" type="text/css" rel="stylesheet"/><![endif]-->
<script>if (typeof module === 'object') {window.module = module; module = undefined;}</script>
<script>
var okta = {
migrateMute: true,
locale: 'en',
debug: false,
deployEnv: '',
userId: '',
settings: {
orgId: '',
orgName: '',
serverStatus: 'ACTIVE',
persona: '',
isDeveloperConsole: '' === 'true',
isPreview: 'false' === 'true',
permissions: []
},
logHasFeatureError: function(message) {
var xhr = new XMLHttpRequest();
xhr.open('POST', '/api/internal/client-logging/has-feature-error', true);
xhr.setRequestHeader('Content-Type', 'application/json');
xhr.send(JSON.stringify({
message: message
}));
}
};
</script>
<script>window.okta || (window.okta = {}); okta.cdnUrlHostname = "//ok6static.oktacdn.com"; okta.cdnPerformCheck = false;</script><script>window.okta || (window.okta = {});window.okta.mixpanel = true;window.okta.mixpanelTrackingSamplingFactors = {"_DEFAULT":1.0};</script><script>if (window) { window.__OKTA_EXPORT_JQUERY__ = true; }</script>
<script src="https://ok6static.oktacdn.com/assets/js/mvc/dll-common/dll.common.hbs.pacpack.8b8889c6e766308429a208de867effde.js" crossorigin="anonymous" integrity="sha384-Izj1uPhYkYPHbVxrKGX885K5SW1khm+mTkvDQ9mSQX8U+hPmS2cz3tx1QTD1XNhm" type="text/javascript"></script><script src="https://ok6static.oktacdn.com/assets/js/mvc/init-dll/main-init-dll.pack.a47d53539d4c4e0aaf81de0af19137df.js" crossorigin="anonymous" integrity="sha384-SuwhJv3QJeVuGGDVasNQVRM5zSKFqabyXrc1olquFHaAUqmdEk31CSpUYF0vdWJm" type="text/javascript"></script><script src="https://ok6static.oktacdn.com/assets/js/saasure.nojquery.min.11832dc981c84effec1e66cca4dd7bde.js" crossorigin="anonymous" integrity="sha384-j3aQGS5bIr8MkWGkoqjzDDNHhMjL12C4AuIQ2x+l/CXyhSzaLSg3Dm5itCdtQK0b" type="text/javascript"></script><!--[if lt IE 9]><script src="https://ok6static.oktacdn.com/assets/enduser/js/vendor/css3-mediaqueries.fa295f0132f5335f352071ca3613a94a.js" crossorigin="anonymous" integrity="sha384-7pU2GSgyec3nzQMUNSuzanfJelP9UCOyHil0bOv+WnPKSS9lNA/tcxPyr7NV2w6c" type="text/javascript"></script><![endif]-->
<script>if (window.module) module = window.module;</script>
</head>
<body id="app" class="no-app ">
<noscript><div id="noscript-mask"></div><div id="noscript-msg" class="infobox infobox-warning infobox-compact"><span class="icon warning-16"></span><h3>Javascript is disabled on your browser.</h3><p>Please enable Javascript and refresh this page to use Okta.</p></div></noscript>
<div id="container">
<iframe id="download-iframe" style="display: none;"><p>Your browser does not support iFrames</p></iframe>
<span class="hide" id="_xsrfToken">null</span><script>
function trackAdminHelpEvent() {
// Check if OktaMetrics has been initialized and has component,
// then tracks the click of global help link in top right of page for appropriate section
if (typeof OktaMetrics !== "undefined" && OktaMetrics.component) {
OktaMetrics.track('Help');
}
}
</script>
<div id="header" class="clearfix">
<div class="primary-nav clearfix">
<div class="container primary-nav-wrap">
<div class="logo clearfix">
<a href="/admin/dashboard"><span class="icon oktamainlogo"></span></a>
</div>
</div>
</div>
</div>
<!--[if gte IE 8]>
<![if lte IE 9]>
<style>
.unsupported-browser-banner-wrap {
padding: 20px;
border: 1px solid #ddd;
background-color: #f3fbff;
}
.unsupported-browser-banner-inner {
position: relative;
width: 735px;
margin: 0 auto;
text-align: left;
}
.unsupported-browser-banner-inner .icon {
vertical-align: text-bottom;
margin-right: 5px;
display: inline-block;
position: static !important;
}
.unsupported-browser-banner-inner a {
text-decoration: underline;
}
</style>
<div class="unsupported-browser-banner-wrap">
<div class="unsupported-browser-banner-inner">
<span class="icon icon-16 icon-only warning-16-yellow"></span>You are using an unsupported browser. For the best experience, update to <a href="https://support.okta.com/help/articles/Knowledge_Article/24532952-Platforms---Browser-and-OS-Support">a supported browser</a>.</div>
</div>
<![endif]>
<![endif]-->
<div id="content" class="clearfix">
<div><a href="#" id="startcontent" class="skiplink"></a></div>
<span class="hide" id="error-code">404</span>
<div class="error-wrap clearfix">
<div class="error">
<img src="https://ok6static.oktacdn.com/assets/img/ui/http-error-404.e21dc7337e238d67a501b4bd3d3c1f42.png" width="340" height="145" alt="404: Page Not Found"/><p class="error-title">Page Not Found</p>
</div>
<div class="error-content">
<h1>We couldn't find the page you were looking for.</h1>
<div class="nav-button-bar">
<a class="nav-button button-primary" href="/">Go to Homepage</a>
</div>
</div>
</div>
<span class="hide" id="st-app">NONE</span>
</body>
</html>
System.debug(res.getBody())