function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Mike WaughMike Waugh 

REST Callout not following the redirect

I am trying to make my app call out to our webserver to synchronize some data but I keep getting "<html><body>You are being <a href="http://www.introhive.com/contacts/export.json">redirected</a>.</body></html>" as a response and the request ends.

 

How do I get the http request to follow through to the endpoint?

 

My code is as follows:

 

    Blob toEncode = Blob.valueof( key + ':' + UserInfo.getUserName());

    System.debug( 'Encoded Auth: ' + Encodingutil.base64Encode(toEncode));

        

    Http h = new Http();

    

    HttpRequest req = new HttpRequest();

    req.setEndpoint('https://www.myrestdomain.com/contacts/export.json');

    req.setHeader('Authorization', 'Basic ' + Encodingutil.base64Encode(toEncode));

    req.setMethod('GET');

    

   HttpResponse response = h.send(req);

    

   System.debug( response.getBody() ); => <html><body>You are being <a href="http://www.introhive.com/contacts/export.json">redirected</a>.</body></html>

 

    

 

Navatar_DbSupNavatar_DbSup

Hi,

 

I have got similar kind of response like

"_____response_______________________________The URL has moved <a href="https://login.salesforce.com/setup/secur/RemoteAccessAuthorizationPage.apexp?source=l86Hcy6qEKtWNqzXVErZDlmcRQs0D_HBE55MLVuP3x8t5wXkyHYyrVx2Xb5JoWzyVOJrnTqMMaWy_Sfomv.j1xklSQ67NPiEbdAN9nhSrzI.D3v6tGdP2eY_YRs4vD0zrK9IAOmlDWzDjTNKgvfmv9uKYmzY3AjIR7CI5q10iQ7n67ai3asLHSiQIjiHqaO4buZeNDcFcf.QZdvR170I5X60uQzdF5DW1sGeOoDTfmBnbvnGDxnDNkTCjShlwdZZcn0w2tRJnzk83g8QYkA.lcqggAjTvH2TBMMOxjloHQq_wT.9dnr7cQ1SbsVH0H3gGo0fX3ICbb8_SnR5PAATP5VNFNg3mFp5BtjGepP3gFqxy4KxsSwMTVgbDptSs6KDlxCcRJTlMG42LGYvTYfywvw6n.300m4U%3D&sdtd=1">here</a>"

, when I made a request to

url = 'https://login.salesforce.com/services/oauth2/authorize?immediate=false&response_type=code&client_id='+consmer_key+'&redirect_uri='+redrct_uri+'&scope=full';

In this case just bring that resonce to the Visualforce page .

Now yo will see it like

You are being redirected (here redirected is a hyperlink) , when you will clik on this you will redirected to the another required page , as of when I used this hyperlink I was redirected to a authorisation page.

In my case I was redicected to RemoteAccessAuthorizationPage .

 

Did this answer your question? If not, let me know what didn't work, or if so, please mark it solved.