You need to sign in to do that
Don't have an account?
Lukesh Karmore
what is the use of RestRequest req = RestContext.request;
in following code
@RestResource(urlMapping='/Account/*')
global with sharing class MyRestResource {
@HttpGet
global static Account doGet() {
RestRequest req = RestContext.request;
RestResponse res = RestContext.response;
String accountId = req.requestURI.substring(req.requestURI.lastIndexOf('/')+1);
Account result = [SELECT Id, Name, Phone, Website FROM Account WHERE Id = :accountId]; return result;
}
}
what is the use of this bold line in above code can any one explain mein simple words.
thank you
@RestResource(urlMapping='/Account/*')
global with sharing class MyRestResource {
@HttpGet
global static Account doGet() {
RestRequest req = RestContext.request;
RestResponse res = RestContext.response;
String accountId = req.requestURI.substring(req.requestURI.lastIndexOf('/')+1);
Account result = [SELECT Id, Name, Phone, Website FROM Account WHERE Id = :accountId]; return result;
}
}
what is the use of this bold line in above code can any one explain mein simple words.
thank you
Plz refer https://www.sfdcstop.com/2019/11/salesforce-integration-tutorial-part-3.html for better understanding on the Integration part.
Hi Lukesh,
Check below references that can give you more details.
https://developer.salesforce.com/docs/atlas.en-us.apexcode.meta/apexcode/apex_methods_system_restrequest.htm
https://developer.salesforce.com/docs/atlas.en-us.apexcode.meta/apexcode/apex_rest_code_sample_restrequest.htm
http://amitsalesforce.blogspot.com/2016/04/rest-api-in-salesforce-execute-rest-api.html
Thanks,