You need to sign in to do that
Don't have an account?
Nurav1982
Exposing a custom object via Apex Webservice
Hello All,
I am new to Salesforce.
We have this requirement.
a) We have a custom object that has 10 fields + 1-2 file attachments.
b) Expose this custom object via a webservice.The sole purpose of this webservice is to retrieve records from this custom object.
c) Our partner then ,using this webservice, will consume the records and load it in his system.
Is this possible to do it in Salesforce ?
Hi,
sample of the web services code.
@RestResource(urlMapping='/customrecods/*')
global with sharing class RESTCustomRecords {
@HttpGet
global static CustomObj__c[] doGet(RestRequest request, RestResponse res)
{
String strName = request.params.get('Name');
String strId = request.params.get('Id');
if( strId != null )
{
//write query here
// return arrRecords;
}
return null;
}
@HttpPost
global static String[] doPost( RestRequest request, RestResponse response )
{
Database.Saveresult saveResult = null;
String[] strResult = new String[2];
String strRecordId = request.params.get('Id');
String strParentId = request.params.get('ParentId');
String strName = request.params.get('Name');
if( strRecordId == null || strRecordId == '' )
{
//make data object of custom object and insert the record
strResult[0] = (saveResult.success) ? 'true' : 'false';
strResult[1] = saveResult.id;
return strResult;
}
return strResult;
}