I am trying to test my Apex class code exposed as rest api. For this, I am making a call to this API using postman. Below is the class I created

global with sharing class SurboChatIntegration {
    global static ResponseClass doPost(){
        SurboChatTranscript chatRequest;
        RestRequest req = RestContext.request;
        String reqBody = (req.requestBody.toString());
        chatRequest = (SurboChatTranscript)json.deserialize(reqBody, SurboChatTranscript.class);
        Account accountObj = new Account(id = chatRequest.AccountId);
        //List<Account> accountObj = [select fields[ALL] from Account where id =:chatRequest.accountId];
        Case caseObj = new Case(id = chatRequest.CaseId);
        //List <Case> caseObj = [select fields[ALL] from Case where id=:chatRequest.caseId];
        SurboChat__c surboChat = new SurboChat__c (ChatBody__c=chatRequest.body, CaseId__c = caseObj.Id, AccountId__c=accountObj.Id, StartTime__c = chatRequest.startTime, EndTime__c=chatRequest.endTime);
        insert surboChat;
        catch(Exception e){
            Integration_Log__c log = new Integration_Log__c();
            log.Component_Name__c='SurboChat Transcript';
            insert log; 
                ResponseClass sc = new ResponseClass();
                sc.status ='ERROR!';
                return sc;
        ResponseClass sc = new ResponseClass();
        sc.status ='Success';
       // String query=[Select id from SurboChat__c where StartTime__c = :chatRequest.startTime AND EndTime__c = :chatRequest.endTime];
        sc.message = chatRequest.surboId;
        return sc;

   public class SurboChatTranscript{
        String surboId;
        String body;
        String accountId ;
        String caseId;
        DateTime startTime;
        DateTime endTime;
        String status;
        String error;

   global class ResponseClass{
        string status{get;set;}
        string message{get;set;}

Below is the request I am making to call the above api

curl --location --request POST 'https://<instance_name>/services/data/v53/SurboChat/SaveChatTranscript' \
--header 'Content-Type: application/json' \
--header 'Authorization: Bearer <token_id>' \
--header 'Cookie: BrowserId=MG4uOQDPEey3pZcptr2XgA; CookieConsentPolicy=0:1' \
--data-raw '{
    "surboId": "2333",
    "body": "This is the surbo chat transcript test we are doing to save it in Salesforce",
    "accountId": "null",
    "caseId": "null",
    "startTime": "2020-08-11:10:10:10",
    "endTime": "2020-08-11:11:10:10",
    "status": "null",
    "error": "null"

With this call, I am getting errors:

[ { "errorCode": "NOT_FOUND", "message": "The requested resource does not exist" } ]

1 Answer 1


Your endpoint https://<instance_name>/services/data/v53/SurboChat/SaveChatTranscript in the postman request is incorrect for custom rest resources. That should be:


This is well described in the documentation of the RestResource Annotation

The URL mapping is relative to https://instance.salesforce.com/services/apexrest/

  • thank you.. this works :)
    – bhavi
    Sep 3, 2021 at 7:32

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .