Saturday, 28 January 2017

Salesforce Apex Class as REST api Get


Salesforce REST Api as Apex Class using Get Method

Salesforce enables the programmer to expose Apex class and methods through REST architecture.

To define an apex class as REST resource @RestResource annotation is used.

@RestResource(urlMapping='/RestApiSample/*')

urlMapping is used to provide url path through which the class can be accessed.

Rest api supports different methods like Get, Post

To define a method as Get, we can use @HttpGet annotation.

RestContext class contains the RestRequest and RestResponse objects.

We can get the parameter using RestContext.

Full code example is shared below:



No comments:

Post a Comment