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
S S MalikS S Malik 

System.LimitException: DML currently not allowed Class.Calloutcontroller.getperformcallout: line 49, column 1

Apex Class
public class Calloutcontroller {
    List<Tutor__c> TutorList ;
   
    // public Calloutcontroller() {
    //  }
    //  public Calloutcontroller(Tutor controller) {
    //  }
    //public Calloutcontroller(ApexPages.StandardController controller) {
    
    public List<consolewrap> ConsoleWrapperList{get;set;}
    public List<consolewrap> getperformcallout(){
     TutorList = new List<Tutor__c>();
    ConsoleWrapperList = new List<consolewrap>();
    HttpRequest req = new HttpRequest();
    HttpResponse res = new HttpResponse();
    Http http = new Http();
    req.setEndpoint('http://www.itutorindia.com/angularjs/api/smallWidget/tutorHourSalesForce');
    //req.setEndpoint('http://52.24.111.14/angularjs/api/smallWidget/tutorHourSalesForce');
    req.setMethod('GET');
    req.setHeader('Content-Type', 'application/json');
    req.setHeader('Accept','application/json');
    res = http.send(req);
    if(res.getstatusCode() == 200 && res.getbody() != null){
    system.debug('Response body result is+++: ' + res.getBody());
    ConsoleWrapperList=(List<consolewrap>)json.deserialize(res.getbody(),List<consolewrap>.class);
    
    /* To save Aoi data in custom object tutor*/
    
    Tutor__c tutorObj;
    system.debug('test1++++++++');
    for (integer i = 0; i<ConsoleWrapperList.size(); i++)
    {
    system.debug('test2++++++++');
    tutorObj = new Tutor__c();
    tutorObj.Class_ID__c = Integer.valueOf(ConsoleWrapperList[i].class_id);
    tutorObj.Tutor_ID__c = Integer.valueOf(ConsoleWrapperList[i].tutor_id);
    tutorObj.Class_Time__c =date.ValueOf(ConsoleWrapperList[i].class_time);
    //system.debug('time is++++ '+tutorObj.Class_Time__c);
    //system.debug('Time values entered');
    tutorObj.Name = ConsoleWrapperList[i].tutor_name;
    tutorObj.E_Mail__c = ConsoleWrapperList[i].tutor_email;
    tutorObj.Tutor_Phone__c = ConsoleWrapperList[i].tutor_phone;
    TutorList.add(tutorObj);
   // system.debug('test3++++++++');
    }
    //system.debug('TutorList++++++++'+TutorList);
    }
    //system.debug('Time values entered222');
    upsert TutorList;
    system.debug('Time values entered+++++++');
    return ConsoleWrapperList;
}
    }
-----------------------------------------------------------
Wrapper class
public class consolewrap {

public String class_id{get;set;}

public String class_time{get;set;}

public String tutor_id{get;set;}

public String tutor_name{get;set;}

public String tutor_email{get;set;} 

public String tutor_phone{get;set;}
}
-------------------------------------------------------------------------------
VF PAGE
<apex:page Controller="Calloutcontroller" title="JSON Tutors table">

<apex:form >

<apex:pageBlock >

<apex:pageBlockTable value="{!performcallout}" var="wrap">

<apex:column headerValue="Class Id" value="{!wrap.class_id}"/>

<apex:column headerValue="Class Time" value="{!wrap.class_time}"/>

<apex:column headerValue="Tutor Id" value="{!wrap.tutor_id}"/>

<apex:column headerValue="Tutor Name" value="{!wrap.tutor_name}"/>

<apex:column headerValue="Tutor Email" value="{!wrap.tutor_email}"/>

<apex:column headerValue="Tutor Phone" value="{!wrap.tutor_phone}"/>

</apex:pageBlockTable>

</apex:pageBlock>

</apex:form>
</apex:page>