public class getContactUsingRESTAPI {

   public static list<Contact> callgetContact (String accId)
              // Create Rest Request                              
              http http= new http();
              HttpRequest feedRequest= new httprequest();
              HttpResponse res1= new HttpResponse ();
            String trimmedResponse = res1.getBody().unescapeCsv().remove('\\');



12:00:26:512 USER_DEBUG [57]|DEBUG|@@@RESPONSE@@[{"message":"Session expired or invalid","errorCode":"INVALID_SESSION_ID"}]

Please advise

Target Org code for response ----

   global with sharing class getContact {
      global static list<contact> fetchAccount(){
        RestRequest req = RestContext.request;
        RestResponse res = Restcontext.response;
        Id accId = req.requestURI.substring(req.requestURI.lastIndexOf('/')+1);

        list<contact> lstcontact =[Select id , name,Phone,Fax,Email from contact where Accountid='001O000000Yk7tl'];

        return lstcontact ;

Please use Workbench and cURL to test if you can invoke the @HttpGet in combination with this Trailhead section.

You also take a look and follow these steps to make sure you have authentification components in place.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.