Preparing a class that can post certain fields on opportunity in JSON format but running into the error "Initial term of field expression must be concrete SOject: Id"
public class oppTrigClass {
public class oppRecord {
public string oppId {get;set;}
public string ownerId{get;set;}
public date cDate{get;set;}
public string stage{get;set;}
}
//
@future(callout = true)
public static void postOppInfo(list<Id> oppIds){
//Create JSON generator
JSONGenerator gen = JSON.createGenerator(true);
gen.writeStartArray();
for(Id oppId : oppIds){
gen.writeStartObject();
gen.writeStringField('Opportunity id', oppId);
gen.writeStringField('Stage', oppId.StageName);
//gen.writeStringField('owner id', oppId.ownerId);
//gen.writeDateField('close date', oppId.cDate);
gen.writeEndObject();
}
gen.writeEndArray();
string jsonOpps = gen.getAsString();
system.debug('Opportunities:' + jsonOpps);
}
}
Can someone please suggest how to overcome this error. Thanks