function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Karthik jKarthik j 

Httpget Annotated method not returning records in inbound callout.

I am making an inbound callout to my salesforce org by adding Id as a parameter to the endpoint and below is my apex code.

@RestResource(urlMapping='/Product/')
global class IntegrationProductsApi {
    
    @httpget
    global static List<Product2> getProducts(){
        Map<String,string> reqParams =  RestContext.request.params;
        string prodId = reqParams.get('Id');
        system.debug('prodId>'+prodId);
        List<Product2> productList=[select Id,ProductCode,Name from             Product2 where Id=:prodId];
        system.debug('productList>'+productList);
        if(productList.size()>0){
            return productList;
        }
        return null;
    }
}
Id which I am passing with endpoint is already there in salesforce DB, but still in the above debug statement I am getting productList as null.

I am new to integration and any help would be appreciated.
Naveen KNNaveen KN
inbound (callIn) and callouts are different. As per the code, it is an inbound custom web service that you exposed to share the product list based on the productId

have you queried the data out of this class, maybe in the SOQL query editor of the developer console to check you have the data for that Id?
 
Karthik jKarthik j
Yeah I tried the above query with the same id in  query editor, it is returning the result but not sure why it is not reflecting in this inbound call.