I am trying to call a REST api from lightning, however i am getting 401, Unauthorized error.

I know this question has been asked previously, but the solution they offered was to use a visualforce page.

I tried to use visualforce page and created a managed package from it. However, after installing the package, the issue I got is org.apache.commons.httpclient.RedirectException: Maximum redirects (100) exceeded

I tried to return UserInfo.getSessionId from AuraEnabled method, however that threw 401 Unauthorized error again.

 public static String getSessionId(){
   return UserInfo.getSessionId();

The rest api request is to same salesforce org itself. How do I call a Rest API by passing authorization code from salesforce using lightning component

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.