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
dotnet developedotnet 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..