• Steve Farmer
  • NEWBIE
  • 0 Points
  • Member since 2016

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 1
    Questions
  • 1
    Replies
Hi,

I am trying to envoke an APEX class I wrote to retrieve cases using REST in Postman. I am unable to figure out how to authenticate to get a propper session established. I created the class in the sandbox. Any help would be appreciated.

Steve
Hi guys, I am new to APEX, and I am trying to create a class to access via REST.
Please let me know what I am doing wrong here:
 
@isTest(SeeAllData = true)
@RestResource(urlMapping='/v1/cases/*')
global with sharing class REST_getCases_V1 {
    
    @HttpGet
    global static Case doGet() {
        RestRequest req = RestContext.request;
        RestResponse res = RestContext.response;        
        String caseId = req.requestURI.substring(req.requestURI.lastIndexOf('/')+1);        
        Case result = [select CaseNumber, status from case where CaseNumber = :caseId]; <<---Line 14
        return result;
    }
}
error:
System.QueryException: List has no rows for assignment to SObject Class.REST_getCases_V1.doGet: line 14, column 1
User-added image

I am going by this sample:
https://youtu.be/C64pLdXmEoo

Any help is appreciated,

Thank you.

Steve