1

I am following this guide to invoke a REST API on salesforce server side and get a JSON response.

  1. I created a salesforce site, and added the VF page
  2. Ensured that the page and classes have access.

When I am invoking the URL as mentioned down below for query I am getting the following response.

{
    "success": false,
    "sObjects": [],
    "requestURI": "/kvh/respondentPortal/get/",
    "params": ["kvh", "respondentPortal", "get", " "],
    "message": "No auth token provided. Please provide one with ?authToken= in the request url"
}

I have kvh since it is a namespaced org.

4

The error seems fairly clear. You need to be having a parameter called 'authToken' in your GET request.

Your code is failing here

 if(RestContext.request.params.get('authToken') == null)
            {
                throw new applicationException('No auth token provided. Please provide one with ?authToken= in the request url');
            }

Check the syntax of your GET URL to see that the authToken is being properly populated. This should fix it.

E.g.

<URL>?param1=value1&authToken='value'&paramx=valuex and so on and so forth

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.