• Steve F
  • NEWBIE
  • 15 Points
  • Member since 2016
  • Developer

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 1
    Questions
  • 2
    Replies
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



 
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