1

Apex class -

@RestResource(urlMapping='/account')

global class createAccount 
{    

    @HttpPost
    global static void createAcc() 
    {

        //-- Data coming from request
        String strFirstName = RestContext.request.params.get('First_Name');
        String strLastName = RestContext.request.params.get('Last_Name');
        String strPhone = RestContext.request.params.get('Phone');
        String strEmail = RestContext.request.params.get('Email');
        String strTitle = RestContext.request.params.get('Title');

        system.debug('RestContext.request.params: '+RestContext.request.params);

        system.debug('First_Name: '+strFirstName);
        system.debug('Last_Name: '+strLastName);
        system.debug('Phone: '+strPhone);
        system.debug('Email: '+strEmail);
        system.debug('Title: '+strTitle);
   }
}

When I check the debug log, the last debug statement shows null value.

12:17:31.033 (33840000)|USER_DEBUG|[21]|DEBUG|RestContext.request.params: {[email protected], First_Name=FirstName, Last_Name=LastName, Phone=+1234567890, ​Title=Mr}
12:17:31.033 (33886000)|USER_DEBUG|[23]|DEBUG|First_Name: FirstName
12:17:31.033 (33929000)|USER_DEBUG|[24]|DEBUG|Last_Name: LastName
12:17:31.033 (33963000)|USER_DEBUG|[25]|DEBUG|Phone: +1234567890
12:17:31.033 (33998000)|USER_DEBUG|[26]|DEBUG|Email: [email protected]
12:17:31.034 (34035000)|USER_DEBUG|[27]|DEBUG|Title: null

POST https://cs10.salesforce.com/services/apexrest/account?First_Name=FirstName&Last_Name=LastName&Phone=+1234567890&[email protected]&​Title=Mr

8
  • How are you calling your REST endpoint? Commented May 8, 2014 at 12:44
  • JavaScript's encodeURIComponent replaces @ with %40, so the first thing to try would be to replace that character in the URI you post to see if that is the problem (i.e. your test URI is incorrectly encoded). Though weird that your first debug output looks correct.
    – Keith C
    Commented May 8, 2014 at 15:03
  • 2
    As a starting point, I recreated you class and request. Using the dev console the output was properly displayed. Check to ensure your URL you are creating does not include and special characters before Title. Your paste also seems to strip off the Title=Mr in the URL. Again, recreating and calling from the dev console works just fine
    – Eric
    Commented May 8, 2014 at 16:14
  • @Swati i tried your code and its working as expected.I am getting correct value for all the debugs including title.I think u must check your log again .There seems to be no issue. Commented May 9, 2014 at 6:34
  • 4
    I'm voting to close this question as off-topic because old question the op has abandoned
    – Eric
    Commented Sep 13, 2016 at 4:49

1 Answer 1

0

As a starting point, I recreated you class and request. Using the dev console the output was properly displayed. Check to ensure your URL you are creating does not include and special characters before Title. Your paste also seems to strip off the Title=Mr in the URL. Again, recreating and calling from the dev console works just fine

Not the answer you're looking for? Browse other questions tagged .