I have configured Plivo SMS in my org. Sending and logging outbound messages is no problem. I have configured a Plivo app to direct inbound SMS to my rest resource to create an inbound record (custom object I've called Plivo_SMS__c), but am having an issue with receiving the "from" number. When I try to define a string labeled "from", I get an error. Here is my basic rest resource:


Global with sharing class smslog{
    global static ID createSMSrecord(String MessageUUID, string From,
        string to, String mtype, string Text) {
        Plivo_SMS__C thisPlivo = new Plivo_SMS__C(
            SMSmessage__c = text);
         insert thisPlivo;
         return thisPlivo.Id;


when I change the string "from" to something like fromnumber, my testing is successful, but the actual POST I receive looks like this:

 {'To': '19165555554', 'From': '19165555555', 'Text': 'Example Message', 'Type': 'sms', 'MessageUUID': '015447-b20c-15r6-a746-06anob21425'}

I also anticipate a similar issue with the string "type" as well. Is there a way to assign a string variable to a key word? I am uncertain as to the correct way to receive and process this post. Thank you in advance for any assistance.

1 Answer 1


There is more than one way to skin a cat get request parameters. The following approach should work just fine for you if you are trying to use reserved words as parameters. Note that type is not a reserved keyword in Apex.

global with sharing class Throwaway
    global static void doStuffWithReservedKeywords()
        String fromValue = RestContext.request.params.get('From');
        String type = RestContext.request.params.get('Type');
  • But I wouldn't use the word Type for a variable name, either, just in case someone later decides they want to use the Type "class"...
    – sfdcfox
    Nov 9, 2016 at 5:00
  • You can just use System.Type if there is a conflict, and since the scoping is very locally constrained in this case, I would have no qualms with using it myself.
    – Adrian Larson
    Nov 9, 2016 at 13:57

You must log in to answer this question.

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