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
DougFriedmanDougFriedman 

Apex REST Error

I have the following Apex REST class and I'm getting the following error when calling it via the API.  The query runs fine in the console, and the error dissapears when I remove the query from the class.   My ultimate goal is to email a Knowledge Article Attachment Ideas?

 

Class: 

 

@RestResource(urlMapping='/attach/*')
global with sharing class SendAttach {
 @HttpGet
    global static String doGet() {
        RestRequest req = RestContext.request;
        RestResponse res = RestContext.response;
        
        List<XXXXXXX__kav> myArticles = [SELECT Id, Article_Attachment__Body__s FROM XXXXX__kav WHERE Id = 'testHardCodedIdGoesHere'];
        
        return 'true';
    }

 

}

 

Error:

 

An unexpected error occurred. Please include this ErrorId if you contact support: 67049153-20127 (1467520363)

WizradWizrad

Maybe im just ignorant to some feature of salesforce but i've never seen a field ending in underscore-underscore-s.

 

Article_Attachment__Body__s

 

DougFriedmanDougFriedman

Thats what you get back when you do an sobject describe call via the API.  I am able to retrieve the Attachment as an encoded string via the REST API (with that field name) and the query above works in the console, so the column name must exist.

WizradWizrad

How big is the article?  Could you be going larger than allowed heap size?

francoisLfrancoisL

Hi Doug,

 

Since you receive a gack error, you should open a salesforce case since it should not thow an error like this one.