I am writing a REST webserviece where i am getting value from third party and then after getting that value i am trying to populate a VF page with those value.

@RestResource (urlMapping = '/Telephony/*')
global with sharing class RestIntegration
    public string cpf {get;set;}

    global static integer GetPatinetInfo()
        Integer success = 0;
        RestRequest req = RestContext.request;
        RestResponse res = RestContext.response;
        //String CPF = req.requestURI.substring(req.requestURI.lastIndexOf('/')+1);
        String CPF = req.params.get('CPF');
        String DOB = req.params.get('DOB');

        String idconsumedor = CPF + DOB.mid(6,2) +  DOB.mid(0,2) + DOB.mid(2,2);

        List<Account> result = [SELECT Id, Name FROM Account WHERE BCC_IDConsumidor__c = :idconsumedor limit 1];
        if(result.size() == 0)
           success = 1;
        Id ids = result[0].id;
        return success;

    public static PageReference callDataEntr(Id ids)
        //Id ids = result[0].id;
        PageReference  pageRef = new PageReference('/apex/BCC_Data_VF?id=ids');

        return  pageRef;

But when I test it through Workbench Rest Explorer, I do not get redirected to any page.

  • You can't redirect a user using a rest endpoint. If you need to handle data from an external service, you should probably save it in a record, and then have the user visit a Visualforce page that loads that record and performs what you need to do. Can you provide more context to what you are trying to achieve here? – Renato Oliveira Oct 29 '17 at 15:04
  • At customer desk third party is installing CTI packet..after getting info from patient over phone they will call our webservice where based on information that we will get in request we will display it in our VF page.. – SFDC Oct 29 '17 at 15:16
  • So actually you will want to create a record to store that information, and then view it on your Visualforce page. You can't redirect a user using REST. – Renato Oliveira Oct 29 '17 at 15:40
  • we are not creating anything but taking values from third party and display those value in VF Page.. – SFDC Oct 29 '17 at 15:42

Just like Renato said, you cannot "redirect" a third party client to a Salesforce Visualforce using a REST service. It just does not make sense: think of it as a box where a third party will input data, it will make stuff happen in Salesforce and they will get a response, at the most with a callback url.

The main issue is that, your requirement, if I have understood correctly, is for a Salesforce user to visualize some kind of data after a third party has called the REST service. Given this scenario, you would need to:

  1. Create a record when the REST service is used which contains the data which you want the end user to see.
  2. Have the Visualforce feed from the data you inserted so when the Salesforce user access that Visualforce, he can see it.

Now, on the other hand, if you want the very user of the REST service to visualize that data, then you should simply return a JSON with the required information. Then, it's the client's (third party app) responsibility to develop a proper interface to visualize the data in your JSON, not yours, since you're the "server" (Salesforce).

I hope that kind of explains both scenarios, since I'm not completely sure which one you're trying to achieve! :)

  • I am trying to do Cloud-to-Cloud Telephony Integration for Inbound Calls..i am stuck at how to populate value receive by IVR into my VF page.. – SFDC Oct 30 '17 at 7:15
  • @SFDC can you be more specific and explain why this doesn't answer your question? Who are the story users?what actions do each have and what reactions do they expect from the system? – Javier García Manzano Oct 30 '17 at 7:25
  • Users are Call Center Operator. What i am trying to achieve is "How to Answer Incoming Phone Calls from Salesforce Service Cloud?" – SFDC Nov 10 '17 at 12:53

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.