• May the Vforce be with you
  • NEWBIE
  • 0 Points
  • Member since 2013

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 0
    Questions
  • 2
    Replies

Hi all. I'm having a problem accessing the REST API from a VF page. Basically, the request performs OK, except for the parameters, which are not being set/do not arrive on the endpoint.

 

I'm using forcetk to avoid the cross domain issue. This is the relevant VF code:

 

<apex:page showHeader="false" sidebar="false" standardStylesheets="false">

    <apex:includeScript value="{!URLFOR($Resource.MyResource, 'jquery-1.9.1.min.js')}"/>
    <apex:includeScript value="{!URLFOR($Resource.MyResource, 'forcetk.js')}"/>
    
    <script type="text/javascript">
        $(document).ready(function() {

            var forceTKClient = new forcetk.Client();
            forceTKClient.setSessionToken('{!$Api.Session_ID}');
            
            forceTKClient.apexrest(
                '/MyRestResource',
                function(data, textStatus, jqXHR) {
                    console.log('SUCCESS - ' + data);
                },
                function(jqXHR, textStatus, errorThrown) {
                    console.log('ERROR - ' + textStatus);
                },
                'GET',
                {'myParameter':'myValue'},
                null,
                false
            );
        });
    </script>
    
</apex:page>

 

And this is the Apex controller for the REST resource:

 

@RestResource(urlMapping='/MyRestResource')
global with sharing class MyRestResource {
    
    @HttpGet
    global static Map<String, String> doGet() {

        Map<String,String> res = new Map<String,String> {
            'received' => 'yes'
        };      
        
        res.putAll(RestContext.request.params);
        return res;
    }

}

 

My custom REST method is reached correctly, and the response from it is returned correctly, but the parameters do never get to my custom REST method. I.e., the response received on the JS callback is

 

{received: "yes"}

 whereas it should be

 

{received: "yes", myParameter: "myValue"}

Inspecting the request sent from the browser I see that the endpoint is

 

https://c.na11.visual.force.com/services/proxy?_=1368023886976

 

 

"myParameter" isn't present anywhere on the browser request.

 

Any hint?

 

Thanks in advance,

Antonio

 

 

Helo All,

I would like to know if there's way to load Home Page Components in the Standard Console Tab's sidebar?

As far as we know, the console tab's side bar display only the 'Recent Items' & 'Recycle' standard components.

 

Basically, we have some HTML Home Page Component (Narrow) that run in every salesforce pages - BUT for pages such as the console we're not able to generate the JS file / HTML code in the component as SF not loading it.

 

As far as I know in the Service Console Tab it's a bit different situation as we can develop specific custom home page component, but our questions refers to the regular console tab.

 

Thanks in advance,

 

  • April 09, 2013
  • Like
  • 0