You need to sign in to do that
Don't have an account?
dotnet develope
URL No Longer Exists for RESTful API
Hi All,
I have created a Rest API and return a string. i got stuck with a error message.
"URL No Longer Exists".
its will be great if anyone could help me on this.
REST API Class @RestResource(urlMapping= '/GetService/*') global with sharing class getTarget { @HttpGet global static String getRestMethod(RestRequest req,RestResponse res) { String name = req.params.get('name'); return 'Hello'+name+', you have just invoked a custom Apex REST web service exposed using REST API' ; } }
Apex Class public class getService { public string getname{get; set;} public string name{get; set;} public PageReference submit() { getname = getNameMethod(name); return null; } public static string getNameMethod(string name) { HttpRequest req = new HttpRequest(); Http http = new Http(); req.setMethod('GET'); string url = 'https://maheshch-developer-edition.my.salesforce.com/Services/apexrest/GetService?name='+name; req.setEndpoint(url); req.setHeader('Authorization', 'OAuth '+UserInfo.getSessionId()); HTTPResponse resp = http.send(req); return resp.getBody(); } }
VF Page <apex:page controller="getService"> <apex:form > <apex:pageBlock > <apex:pageBlockSection > <apex:pageBlockSectionItem > <apex:outputLabel for="name">Name</apex:outputLabel> <apex:inputText id="name" value="{!name}"/> </apex:pageBlockSectionItem> </apex:pageBlockSection> </apex:pageBlock> <apex:commandButton action="{!submit}" value="Submit"> </apex:commandButton> <br/><br/> {!getname} </apex:form> </apex:page>
Thanks in advance..