+ Start a Discussion
GYAN ANDRUSGYAN ANDRUS 

Hi Anyone please help me have created the webservice class for custom object,I have given the URL in remote settings,But when i try to give the URL in Postman(POST),Its not showing the record

@RestResource(urlMapping='/WSItemMasterProductFacilities')
global class  WSItemMasterProductFacilities {
    @HttpPost
    global static List<PBSI__PBSI_Item__c> ItemMasterProductFacilities()
    {
       List<PBSI__PBSI_Item__c> itemMaster;
       
        try
        {
         RestRequest req = RestContext.request;
         String NameValue = req.params.get('name');   
         itemMaster = [Select id,Name from PBSI__PBSI_Item__c];   
         return itemMaster;  
            }
        catch(Exception e)
        {
        System.debug('Line Number is = '+e.getLineNumber()+' Message is = ' +e.getMessage());
         }
        return itemMaster;  
        
    }
}



The URL which i have added in remoteSite Setting:https://aci--uat.cs23.my.salesforce.com
Pankaj_GanwaniPankaj_Ganwani
Hi Gyan,

Just append '*' at the end of your urlMapping parameter value like and try:
urlMapping='/WSItemMasterProductFacilities/*'

Apart from that, any error or exception you are getting while invoking this webservice? Check for the debug logs as well setting the context user same as that of you are using while calling your webservice.
GYAN ANDRUSGYAN ANDRUS
Hi Pankaj,Thanks for the reply...but this code not working now..Can u pls tell where my error


@RestResource(urlMapping='/WSItemMasterProductFacilities')
global class  WSItemMasterProductFacilities {
    
    @HttpPost
    global static List<PBSI__PBSI_Item__c> getWidgets() {
    
    RestRequest req = RestContext.request;
        RestResponse restRes = RestContext.response;
        Response res = new Response();
        //Headers from request
        String accountId = req.headers.get('Account-ID');
        System.debug('accountId in WSBorrowerReports = '+accountId);
        if(accountId == null)
        {
            res.errorCode = peer.Constants.INVALID_INPUT;
            res.status = peer.Constants.ERROR;
            res.message = 'ACCOUNT_ID_NOT_PRESENT_IN_HEADER';
            restRes.statuscode = peer.Constants.HTTP_BAD_REQUEST;
            return res;
        }
     try
        {
          String j;
         RestRequest req = RestContext.request;
         String NameValue = req.params.get('name');
         List <PBSI__PBSI_Item__c> itemMasterList = new List<PBSI__PBSI_Item__c>();
         PBSI__PBSI_Item__c  loanDisbursalTrans;
         WrapperItemMasterparticipatedList  ItemTrans = new WrapperItemMasterparticipatedList();
         List<WrapperItemMasterparticipatedList> ItemTransData = new List<WrapperItemMasterparticipatedList>();

        
         itemMasterList  = [Select id,Name from PBSI__PBSI_Item__c];
         for(j=0;j<itemMasterList.size();j++)
                {
                ItemTrans = new WrapperItemMasterparticipatedList();
                loanDisbursalTrans = itemMasterList.get(j);
                ItemTrans.entity_id  = loanDisbursalTrans.name;
                ItemTransData.add(ItemTrans)
                
            }
        
        //Sending Response
            res.ItemTransData  = ItemTransData;
          restRes.statuscode = peer.Constants.HTTP_OK;
            res.status = peer.Constants.SUCCESS;
            return res;
            }
         catch (Exception e) {
            System.debug('Exception e is ='+e);
            res.errorCode = 'Line number= '+e.getLineNumber()+' Message is= ' +e.getmessage();
            res.status = peer.Constants.ERROR;
            res.message = 'Internal Exeption Occurred';
            restRes.statuscode = peer.Constants.HTTP_INTERNAL_ERROR;
            return res;
        
    }
}