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
sarvesh001sarvesh001 

[{"message":"HTTPS Required","errorCode":"UNSUPPORTED_CLIENT"}]

Hi,

 

I have got error

 [{"message":"HTTPS Required","errorCode":"UNSUPPORTED_CLIENT"}]

 

when i call service hosted in site from apex page .

 my code is below

 

my source code:

 

<apex:page controller="getservice2">
<apex:form >
<apex:commandButton action="{!getResult}" value="Submit"> </apex:commandButton>
<br/><br/> {!myresponse}
</apex:form>
</apex:page>

 

public class getservice2
{
public String myresponse{get;set;}
public Pagereference getResult()
{
HttpRequest req = new HttpRequest();
Http http = new Http();
req.setMethod('GET');
String url = 'http://sarveswararao-developer-edition.ap1.force.com/services/apexrest/GetService ';
req.setEndpoint(url);
req.setHeader('Authorization', 'OAuth '+UserInfo.getSessionId());
HTTPResponse resp = http.send(req);
myresponse=resp.getBody();
return null; }
}

 

my target code in site

 

@RestResource(urlMapping='/GetService/*')  
global with sharing class getservice1
{      
     @HttpGet     
     global static String postRestMethod()     
     {          
          return 'Hi, You have invoked getservice1 created using Apex Rest and exposed using REST API';        
     }
}

 

please suggest me 

 

Thanks ,

Sarvesh.

 

 

Best Answer chosen by Admin (Salesforce Developers) 
~Onkar~Onkar

Try this.

 

You can change the security setting in your Salesforce account to allow API communication over HTTP as follows:

 

  1. Log into Salesforce.com.
     
  2. Click Setup, click Security Controls, and then click Session Settings.
     
  3. Uncheck the option labeled Require secure connections (HTTPS).

 

 

All Answers

~Onkar~Onkar

Try this.

 

You can change the security setting in your Salesforce account to allow API communication over HTTP as follows:

 

  1. Log into Salesforce.com.
     
  2. Click Setup, click Security Controls, and then click Session Settings.
     
  3. Uncheck the option labeled Require secure connections (HTTPS).

 

 

This was selected as the best answer
sarvesh001sarvesh001

HI Onki3,

 

Thank you soo much its working you greate.....


. Thanks, sarvesh.