I need to create a REST (or REST-like) API for my SF application. After reading https://salesforce.stackexchange.com/a/19058/3382, my thought was to simply use the @RestResource annotated classes because I'd like to not recreate what SF provides out-of-the-box.

However, due to my sharing model, I cannot allow access to the standard SF REST API which is a byproduct of using the annotated classes.

I'm thinking I could come close to creating the REST-like service but I need to know the appropriate HTTP verb (GET, POST, PUT, DELETE) used for the request. But I can't figure out what the verb is in my Apex controller. ApexPages.currentPage().getHeaders() doesn't contain the verb and ApexPages.currentPage().getHeaders() is just a combined map of post and url parameters.

Have I hit the end of the road with this approach? Am I restricted to just create a JSON based API using only GETs and POSTs?

  • I just realized this question was my fault. Irony, I suppose.
    – sfdcfox
    Commented Nov 8, 2013 at 1:36

1 Answer 1


You can't get to the HTTP verb in Visualforce, nor can you even influence something simple like the status code. Given the rather severe limitations in place, you'll have to be a bit more creative. You can, for example, set a 'X-HTTP-Verb' header that you could read in Visualforce (with the true action always set to GET or POST). You could also include it as a URL parameter or as part of the payload. Yes, I realize it's not a "true REST" solution, but we're working within the bounds of the platform. Also remember that your payload has to be url encoded with normal name-value pairs to work.

  • do we have a way to read HTTP verbs in visualforce context? Commented Feb 9, 2022 at 10:19

You must log in to answer this question.

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