You need to sign in to do that
Don't have an account?
beastaw56
Rest Resource Post to VF Page
I have created a rest resource so that when a post is sent to the /services/apexrest/CallCenter I want it to update my visualforce page CallCenter. I wrote something simple for just proof of concept however I cant get any of the post parameters to show up on my visual force page. I am using hurl.it so i know it is hitting the method correctly because it is returning a 200 ok with the Name variable in the response body. Can someone please advise what I am doing wrong or point me in the right direction of getting my HTTP post content onto my VF page.
More Information: I am using a custom site to skip authentication. I have enabled the class and the VF page for my site so i do not think that is the issue. I am passing the Name parameter to the variable String which i initialize as "hi" and then i send the post and my thoughts were after I hit the reload button to rerender the output panel my parameter would be there. I am sending my post via JSON {"Name":"hey"}
@RestResource(urlMapping='/CallCenter')
global without sharing class CallCenterController{
Public string session {get;set;}
Public String dial {get; set;}
Public String callString {get; set;}
public static String test {get; set;}
public static String post;
global CallCenterController()
{
test = 'hi';
}
@HttpPost
global static String createHistory(String Name) {
test = Name;
return Name;
}
<apex:page showHeader="false" sidebar="false" controller="CallCenterController">
<apex:form >
<apex:PageBlock >
<center><apex:selectList value="{!callString}" id="equip" size="1">
<apex:selectOptions value="{!calls}" />
</apex:selectList></center>
<apex:outputPanel id="yes">
<center><apex:outputText value="{!test}" /></center>
</apex:outputPanel>
<apex:commandButton value="reload" rerender="yes" />
</apex:PageBlock>
<apex:PageBlock >
<center><apex:commandButton action="{!call}" value="Call" /></center>
<center><apex:inputText maxlength="11" value="{!dial}" /></center>
</apex:PageBlock>
</apex:form>
</apex:page>
More Information: I am using a custom site to skip authentication. I have enabled the class and the VF page for my site so i do not think that is the issue. I am passing the Name parameter to the variable String which i initialize as "hi" and then i send the post and my thoughts were after I hit the reload button to rerender the output panel my parameter would be there. I am sending my post via JSON {"Name":"hey"}
@RestResource(urlMapping='/CallCenter')
global without sharing class CallCenterController{
Public string session {get;set;}
Public String dial {get; set;}
Public String callString {get; set;}
public static String test {get; set;}
public static String post;
global CallCenterController()
{
test = 'hi';
}
@HttpPost
global static String createHistory(String Name) {
test = Name;
return Name;
}
<apex:page showHeader="false" sidebar="false" controller="CallCenterController">
<apex:form >
<apex:PageBlock >
<center><apex:selectList value="{!callString}" id="equip" size="1">
<apex:selectOptions value="{!calls}" />
</apex:selectList></center>
<apex:outputPanel id="yes">
<center><apex:outputText value="{!test}" /></center>
</apex:outputPanel>
<apex:commandButton value="reload" rerender="yes" />
</apex:PageBlock>
<apex:PageBlock >
<center><apex:commandButton action="{!call}" value="Call" /></center>
<center><apex:inputText maxlength="11" value="{!dial}" /></center>
</apex:PageBlock>
</apex:form>
</apex:page>
Need some more information on this issue,
Enable debug logs and see for the logs if we can fund a clue where exactly the code is breaking.
Regards,
Ashish