Anonmous asked 3 months ago

Public API issue

as per your instruction, I have created an API and site also. did not get list of data from api.

API Code -

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

global with sharing class CaseTHNRecords {

/*global class RestApi_Result {

//webservice String message='';

webservice List CaseList = new list() ;

}*/

/*-------Post------*/

@HttpPOST

global static string StatusRecord(String SearchKeyword){

List CaseList = new list() ;

RestRequest request = RestContext.request;

// RestApi_Result rapi = new RestApi_Result();

Integration_Log__c ILog= new Integration_Log__c();

List casedetails = new List();

try{

ILog.Request__c = SearchKeyword;

ILog.API_Name__c ='CaseTHNRequiredRecord';

if(String.isNotBlank(SearchKeyword) ){

casedetails=[SELECT Id,CaseNumber,SAP_ID__c,Customer_Name__c,Zone__c,PTSA_Completion_dates__c,State__c,Academic_Manager__c,Location__c,THN_1_Board__c,THN_2_Board__c,THN_3_Board__c,THN_4_Board__c,THN_5_Board__c,THN_1_THN_Required__c,THN_2_THN_Required__c,THN_3_THN_Required__c,THN_4__c,THN_5_THN_Required__c FROM Case WHERE Customer_Name__c Like : '%'+SearchKeyword+'%' AND (THN_1_THN_Required__c='Yes' OR THN_2_THN_Required__c='Yes' OR THN_3_THN_Required__c='Yes' OR THN_4__c='Yes' OR THN_5_THN_Required__c='Yes')];

if(casedetails.size()>0){

for(Case c : casedetails){

CaseList.add(c);

// rapi.CaseList.add(c);

}

// rapi.message = 'Case Records feched Successfully';

ILog.status__c='Success';

ILog.response__c='Case Records feched Successfully '+CaseList;

// ILog.response__c='Case Records feched Successfully '+rapi;

}else{

// rapi.message = 'Case Records feched Successfully';

ILog.status__c='Success';

// ILog.response__c='No record was found for the keyword you send '+rapi;

}

}else{

//rapi.message = 'Empty case details';

ILog.status__c='203';

ILog.response__c='Empty case details';

}

Insert ILog;

}

catch(Exception e){

try{

ILog.response__c='Exception'+e.getMessage();

insert ILog;

}

catch(Exception ex){

}

// return rapi;

}

return SearchKeyword;

}

}

0 0 Answers 2

Answers

Asif Ali answered 3 months ago

Remove with sharing keyword from your class.

thumb_up 0 thumb_down 0

Asif Ali answered 3 months ago

Remove with sharing keyword from your class.

thumb_up 0 thumb_down 0

Login to vote and answer the question.

Get notified of new posts