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
Lucas Wright 12Lucas Wright 12 

RestResource Class - Variable does not exist

Hello, I have a JSON2Apex Class to parse the JSON response for a web service but my REST Update class isn't working with it, i'm getting a variable does not exist error on id. It's probably something really simple but I've barely gotten my head around Hello World so far, if anyone has any suggestions?

Here's my PUT Class:
 
@httpput
      global Static string fetchAccount(){
      RestRequest req = RestContext.request;
      RestResponse res = Restcontext.response;
      string jsonString=req.requestBody.tostring();
      JSON2Apex wResp=(JSON2Apex) JSON.deserialize(jsonString,JSON2Apex.class);    
          Patient__c obj=new Patient__c();
      obj=[select id from Patient where Id=:wResp.id];
      update obj;
      return 'Success';
      }
       global class JSON2Apex{
       global string EMPI;
      }

I can post the JSON2Apex if that's necessary but it's quite lengthy so didn't want to include if it wasn't necessary!