Introduction
Force.com has released its REST API as a lightweight channel to access data on the platform(cloud). The basic framework remains the same for REST based services. Request and response can flow in XML or JSON format. The beauty of RESTful service is that its very lightweight and easy to use as compared to SOAP based services.
We will quickly jump over to code that explains how to create a RESTful service on Force.com using Apex.
Diving deep into code:
- We need a class with keyword "@RestResource" to signify the class responsible for handling HTTP requests and act as REST based web service. Make sure the class has global access specifier.
- The urlMapping property allows us to set path where the service will be available. This is process of setting up the endpoint for service. Example: https://
.salesforce.com/services/apexrest/showAccounts - Include @HttpGet keyword before method name for denoting a method to respond on a HTTP GET request; include @HttpPost keyword before method name for denoting a method to respond on a HTTP POST; include @HttpDelete keyword before method name for denoting a method to respond on a HTTP DELETE. Similarly for HTTP PUT and PATCH methods
- Make sure that methods responsible for handling HTTP requests have global access specifier and static keyword with them.
- The awesome feature is that you can set return type as primitive type, standard objects or custom objects within your salesforce.com development environment. In this example the list of accounts will be returned to client invoking the service.
- In order to pass parameters to service, you can use RestRequest object in a method. example:
- The limitation here is that within a RESTful apex class you can have only one method with @HttpGet keyword.i.e. one method can respond to HTTP GET requests in this class or URL path. same applies for @HttpPost, @HttpDelete, @HttpPut, @HttpPatch
Live Action:
In order to consume this service we need a client that can make HTTP calls to the respective endpoint where service is listening for requests. You can write your client using cURL, java, c, c++,etc
The main step to consume this service is to go through OAuth 2.0 authorization flow to access the resources protected by Force.com platform.
For ease I will use Advanced REST client for Chrome to demo this:
Set Endpoint:
Set body :
grant_type=password&client_id=your_clientid_here&client_secret=your_client_secret_here&username=your_username&password=your_password_here *Append your security token if your IP, from where you are invoking the serviceis not in IP whitelist.
Response you get:
{"id": "https://.salesforce.com/id/00DO00000004qZHMAY/00590000000G0keAAC ","issued_at": "1338103748715","instance_url": " ","signature": "N++wJCOHvBdyxR9TTa8VpLkRdBGODgvf5VLmgNhdFHQ=","access_token":"00DO00000004qZH!ARYAQD9cEL5NSrHrjHFwuQcSh5ktdbGLobvF8NiasAuYwZ7sm80G48Mt9sdCPsT42_Ff69ieOe9dozP_BYEASuvA_BTPwgP_"}
Screenshot:
I will make a HTTP POST request to endpoint:https://cs5.salesforce.com/services/oauth2/token*When trying this make sure you replace cs5 with appropriate salesforce.com instance
Set body :
grant_type=password&client_id=your_clientid_here&client_secret=your_client_secret_here&
Response you get:
{"id": "https://
Screenshot:
Keep this access_token as you need it to invoke the RESTful service.
Invoking the service:
Now we are ready to invoke the service we just created.
Set Endpoint:
I will make a HTTP GET request to endpoint(since method is defined with keyword @HttpGet):
https://cs5.salesforce.com/services/apexrest/showAccounts
*When trying this make sure you replace cs5 with appropriate salesforce.com instance
Set Header:
Authorization: OAuth 00DO00000004qZH!ARYAQH.xMKtnnchDH6zTYvkMMYRLIflZgGiZ74EXgTsRyowAUwyk5Xcc1ZoH3C.sZ4oMnsfioPFbKdhlTSdI02hjQPF2FX_0
Response you get:
[
{
"attributes": {
"type": "Account",
"url": "/services/data/v25.0/sobjects/Account/001O00000056mOkIAI"
},
"Name": "Google",
"Id": "001O00000056mOkIAI"
},
{
"attributes": {
"type": "Account",
"url": "/services/data/v25.0/sobjects/Account/001O0000003oCQnIAM"
},
"Name": "Microsoft",
"Id": "001O0000003oCQnIAM"
},
{
"attributes": {
"type": "Account",
"url": "/services/data/v25.0/sobjects/Account/001O00000056mOpIAI"
},
"Name": "Facebook",
"Id": "001O00000056mOpIAI"
},
{
"attributes": {
"type": "Account",
"url": "/services/data/v25.0/sobjects/Account/001O00000056mO2IAI"
},
"Name": "FourSquare",
"Id": "001O00000056mO2IAI"
}
]
screenshot:
This shows the list of accounts in your environment.
I hope this blog help you understand and create RESTful services in Force.com.
Cheers !
252 comments:
«Oldest ‹Older 201 – 252 of 252At QuickBooks Support Services, we have been a group of some of the most experienced QuickBooks Advisors. We have been working a day and 1 week for the week to provide QuickBooks Accounting Support Service from our toll-free Accounting Support Service.
Lovely blog with much more interesting article, I will keep on reading your update. Thanks for the share Web Design Company in Bangalore | Web Development Company in Bangalore | Website Developers in Bangalore | Top Web Design Company in Bangalore
Even when you are feeling that enough time is odd to call for help, just pick up your phone and dial us at QuickBooks Tech Support Phone Number because we provide our support services 24*7.
Thank you for sharing such a nice and interesting blog with us. I have seen that all will say the same thing repeatedly. But in your blog, I had a chance to get some useful and unique information.
Workday Online Training
There are many QuickBooks Payroll Support Number options made available because of the online kind of QuickBooks varying upon the need of accounting professionals and subscription plans. QuickBooks Payroll Support Phone Number as well provides all possible help with the users to utilize it optimally. Someone who keeps connection with experts is able to realize in regards to the latest updates.
Here we will update you the way you can obtain QuickBooks enterprise support telephone number or simple recommendations for connecting QuickBooks Enterprise Support Number. QuickBooks is financial software that will assist small enterprise, large business along with home users.
There you'll need QuickBooks Tech Support Phone Number for QuickBooks Pro-advisors, the certified experts with tremendous experience focusing on QuickBooks errors and Data damage related issues. Dial QuickBooks Help Number for complete diagnostics of your QuickBooks Data files for Errors and accounting issues.
QuickBooks enterprise possesses the ability to keep a track of over 100,000 customers and vendors. Also, add over 30 users to the company data file. However, with such responsibilities, the software can be a little complicated to use. That is why we train our tech team to be completely equipped when it comes to guiding you through the data backup option. We make sure to keep a record of all of your graphics, data files and invoices. QuickBooks enterprise consists of a lot of pliable features that are actually not as complicated as they sound. So, any queries you might be harboring will be dealt with in the most professional manner. That is, once you connect with our QuickBooks Enterprise Technical Support Number team.
Hiii...Thanks for sharing great info...Nice post...Keep move on...
Salesforce Training Institutes in Hyderabad
The QuickBooks Premier Support stays top-notch while the technicians who will be going to cope with your queries are trained to be practical and versatile with regards to taking quick decisions that may instantly solve the reported error.
This as a type of QuickBooks Payroll Support Phone Number offers payroll and accounts management solutions for businesses of small and medium sizes. The lightweight design and simple functionality with this software makes it well suited for use by anybody who hadn’t had any experience of handling any accounting software in past times.
Wonderful blog.
SAP Training in Chennai
SAP ABAP Training in Chennai
SAP Basis Training in Chennai
SAP FICO Training in Chennai
SAP MM Training in Chennai
SAP PM Training in Chennai
SAP PP Training in Chennai
SAP SD Training in Chennai
Very nice blog, Thanks for sharing this informative blog..Keep posting Website Design Companies in Bangalore | Top Web Design Company in Bangalore | Web Designing in Bangalore | Web Designing Company in Bangalore
Any QuickBooks user faces any sort of identified errors in their daily accounting routine; these errors can differ from one another to a large degree, so QuickBooks Tech Support Phone Number dedicated QuickBooks Payroll Pro-Advisers are well loaded with their tools and expertise to give most effective resolutions right away to the customers.
Thanks for Post.It's truly informative will surely keep visiting the website.
salesforce training in Newyork
salesforce expert developer job placement
Hi this is the best info you provided azure online training hyderabad
thanks for your post sql course
Thanks for sharing such a great blog Keep posting.
sales automation tools
sales automation crm
sales automation process
business directory
b2b database providers in India
Salesforce provides an option for Alternative Asset Managers who want to use Salesforce with functionality geared toward their industry: the Salesforce Private Equity/Venture Capital template.
Salesforce Service Cloud
nice..
how to hack chromebook using crosh
hack tp link wifi username and password
brac ngo written test question
whatsapp ethical hacking
react js developer resume india
integer max value javascript
binatone wifi hack
a certain sum of money amounts to rs.1300 in 2 years and to rs. 1525 in 3.5 years. find the sum and the rate of interest
she spent most of her time tomusic
she most of her time tomusic
The development of artificial intelligence (AI) has propelled more programming architects, information scientists, and different experts to investigate the plausibility of a vocation in machine learning. Notwithstanding, a few newcomers will in general spotlight a lot on hypothesis and insufficient on commonsense application. Machine Learning Final Year Projects In case you will succeed, you have to begin building machine learning projects in the near future.
Projects assist you with improving your applied ML skills rapidly while allowing you to investigate an intriguing point. Furthermore, you can include projects into your portfolio, making it simpler to get a vocation, discover cool profession openings, and Final Year Project Centers in Chennai even arrange a more significant compensation.
Data analytics is the study of dissecting crude data so as to make decisions about that data. Data analytics advances and procedures are generally utilized in business ventures to empower associations to settle on progressively Python Training in Chennai educated business choices. In the present worldwide commercial center, it isn't sufficient to assemble data and do the math; you should realize how to apply that data to genuine situations such that will affect conduct. In the program you will initially gain proficiency with the specialized skills, including R and Python dialects most usually utilized in data analytics programming and usage; Python Training in Chennai at that point center around the commonsense application, in view of genuine business issues in a scope of industry segments, for example, wellbeing, promoting and account.
nice..............!
inplant training in chennai
inplant training in chennai for it.php
panama web hosting
syria hosting
services hosting
afghanistan shared web hosting
andorra web hosting
belarus web hosting
brunei darussalam hosting
inplant training in chennai
very nice post...
inplant training in chennai
inplant training in chennai
inplant training in chennai for it
Australia hosting
mexico web hosting
moldova web hosting
albania web hosting
andorra hosting
australia web hosting
denmark web hosting
good...
internship in chennai for ece students
internships in chennai for cse students 2019
Inplant training in chennai
internship for eee students
free internship in chennai
eee internship in chennai
internship for ece students in chennai
inplant training in bangalore for cse
inplant training in bangalore
ccna training in chennai
Thanks for sharing such informative post..
Web Design and Development Bangalore | Web Designing Company In Bangalore | Web Development Company Bangalore | Web Design Company Bangalore
t is best blogs ....
civil-engineer-resume-format
client-service-executive-resume-sample
cognos-developer-resume-samples
college-lecturer-resume
college-lecturer-resume-sample
commercial-assistant-resume-sample
compliance-officer-resume-samples
computer-teacher-resume-format
computer-teacher-resume-sample
cordova-developer-resume-sample
Thank you for sharing the informative blog. Understood lots of things from your blog.
Please also read my topics about:
Salesforce cpq transformation
Salesforce integration services
Salesforce service cloud integration
salesforce optimization
They will not only help you solve your issues regarding QB Errors but will also give you more information about such errors so that the next time you encounter an error, you are able to solve them on your own. Do contact our experts by calling QuickBooks Enterprise Support Phone Number . If you would like to learn how to Troubleshoot Quickbooks Error 9999, you can continue reading this blog.
Nice Blog. Very Impressive.
Data Science Training Course In Chennai | Data Science Training Course In Anna Nagar | Data Science Training Course In OMR | Data Science Training Course In Porur | Data Science Training Course In Tambaram | Data Science Training Course In Velachery
SAMA TECHNICAL SERVICE is the experienced company of Home appliances repair in Dubai Abu Dhabi and all over UAE. We do repair washing machines, Dryer machines, Dishwashers, Fridge freezers, Refrigerators, Cooking range, Air conditioners, and many others. We have thousands of appliance repair engineer teams who can fix all types of problems within a short time.
Home appliance repair Dubai
Home appliance repair Abu Dhabi
Appliance repair Dubai
Cool blog thanks..
SAP Training in Chennai
Java Training in Chennai
Hardware and Networking Training in Chennai
CCNA Training in Chennai
AWS Training in Chennai
Oracle Traning in Chennai
Web Designing Training in Chennai
QTP Training in Chennai
Selenium Training in Chennai
SAP Training Institute in Chennai
Informative Blog
CCNA Training in Chennai
Hardware and Networking Training in Chennai
SAP Training in Chennai
Software Testing Training in Chennai
AWS Training in Chennai
Cool Post.
SAP Training in Chennai
AWS Training in Chennai
Wonderful Post.
Wonderful post.
AWS Training in Chennai
Nice post. By reading your blog, i get inspired and this provides some useful information. Thank you for posting this exclusive post for our vision. Really you have done great job,There are may person searching about that now they will find enough resources by your post
Data Science Training In Chennai
Data Science Online Training In Chennai
Data Science Training In Bangalore
Data Science Training In Hyderabad
Data Science Training In Coimbatore
Data Science Training
Data Science Online Training
Excellent
IICT
SAP Training in Chennai
Hardware and Networking Training in Chennai
AWS Training in Chennai
Oracle Training in Chennai
Cool
.Net Training in Chennai
Job Oriented Training in Chennai
Oracle Fusion Training in Chennai
PHP Training in Chennai
Pearson Vue Exam Center in Chennai
Awesome
Webdesign Training in Chennai
Java Training in Chennai
Software Testing Training in Chennai
Datwarehousing Training in Chennai
CCNP Training in Chennai
Amazing
Multimedia Training in Chennai
IBM Training in Chennai
Mobile App Developemt Training in Chennai
Cloud Computing Training in Chennai
QTP Training in Chennai
Superb
Selenium Training in Chennai
Microsoft Azure Training in Chennai
Informative
SAP Training in Chennai
AWS Training in Chennai
QTP Training in Chennai
CCNA Training in Chennai
Hardware and Networking Training in Chennai
Awesome Post.
Hardware and Networking Training in Chennai
AWS Training in Chennai
SAP Training in Chennai
Software Testing Training in Chennai
Pearson Vue Exam Center in Chennai
I am reading your post from the beginning, it was so interesting to read & I feel thanks to you for posting such a good blog, keep updates regularly.i want to share about websphere online training .
Good Post! , it was so good to read and useful to improve my knowledge as an updated one, keep blogging.After seeing your article I want to say that also a well-written article with some very good information which is very useful for the readers....thanks for sharing it and do share more posts likethis. https://www.3ritechnologies.com/course/tableau-online-training-certification/
Good Post! , it was so good to read and useful to improve my knowledge as an updated one, keep blogging. After seeing your article I want to say that also a well-written article with some very good information which is very useful for the readers....thanks for sharing it and do share more posts like this.
SAP Online Training
Tremendous blog quite easy to grasp the subject since the content is very simple to understand. Obviously, this helps the participants to engage themselves in to the subject without much difficulty. Hope you further educate the readers in the same manner and keep sharing the content as always you do.
Data Science training
Really I appreciate the effort you made to share the knowledge. The topic here I found was really effective...
Data Science Training in Gurgaon
Good Post! , it was so good to read and useful to improve my knowledge as an updated one, keep blogging. After seeing your article I want to say that also a well-written article with some very good information which is very useful for the readers....thanks for sharing it and do share more posts like this.
Data Analytics Training in Gurgaon
Nice Post!!
Please look here at Brochure Design Company in Tirupur
Needed to compose you a very little word to thank you yet again
regarding the nice suggestions you’ve contributed here.
mysql course in chennai
unix shell scripting training in chennai
are you looking for architect in pune In this, there are a lot of options available for all people. As everyone wants to have his/her own home.
Thanks for valuable information, keep posted more. Software Testing Course in Pune
Post a Comment