You need to sign in to do that
Don't have an account?
[{"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.
Try this.
You can change the security setting in your Salesforce account to allow API communication over HTTP as follows:
All Answers
Try this.
You can change the security setting in your Salesforce account to allow API communication over HTTP as follows:
HI Onki3,
Thank you soo much its working you greate.....
. Thanks, sarvesh.