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
Sreenu Reddy 16Sreenu Reddy 16 

REST API class error

Hi Floks....I  got some issue here . please help on this. my issues is 
System.HttpResponse[Status=Internal Server Error, StatusCode=500]
This is my code :
public class RESTExample {
  public String result{set;get;}   
  public string grant_type{set;get;}
  public string Accesstoken{set;get;} 
  public string username{set;get;}
  public string password{set;get;}
  public string client_id{set;get;}
  public string client_secret{set;get;} 
    public string getAccesstoken(){     
    String reqbody ='grant_type='+password+'&client_id='+client_id+'&client_secret='+client_Secret+'&username='+username+'&password='+password; 
      Http p= new Http (); 
      HttpRequest req= new HttpRequest ();
      system.debug('@@@@the reponse value is ###'+req.getbody()); 
         HttpResponse res = p.send(req);  
         system.debug('###the reponse value is@@@ '+res.getbody()); 
         //system.debug('#### the value is %%%%%'+res);            
     // Map<String, String> results = (Map<String, String>) JSON.deserializeUntyped(res.getBody()); 
     // system.debug('@@@Access token value&&&'+ result);
       String accessToken ; 
       System.JSONParser parser=JSON.createParser(result);
             while (parser.nextToken() != null)  {
                  if ((parser.getCurrentToken() == JSONToken.FIELD_NAME))
                                            String fieldName = parser.getText();
                                            if (fieldName == 'access_token') 
                                                accessToken = parser.getText();
         catch (Exception e){
     return accessToken;