I have this code:
@HttpPost
global static String doPost() {
RestRequest req = RestContext.request;
RestResponse res = RestContext.response;
if(req.params.get('action') == 'create'){
System.debug('json'+req.requestbody);
evticket__c ticket = createTicket(req);
return 'yes';
}
else{
return 'no';
}
}
public class TicketObject {
String Subject;
String Description;
List<CommentObject> Comments = new List<CommentObject>();
public TicketObject(String s, String d)
{
Subject = s;
Description = d;
}
}
public static evticket__c createTicket(RestRequest req){
//req.requestBody.toString();
System.debug(req.requestbody.tostring());
TicketObject ticketObject = (TicketObject)JSON.deserialize(req.requestbody.tostring(), TicketObject.class);
evticket__c newTicket = new evticket__c(Subject__c = ticketObject.Subject, Description__c = ticketObject.Description);
//newTicket.Subject__c = 'test1';
//newTicket.Description__c = 'test1';
insert newTicket;
return newTicket;
}
in this line of code:
TicketObject ticketObject = (TicketObject)JSON.deserialize(req.requestbody.tostring(), TicketObject.class);
i get this error:
Compilation error: Variable does not exist: TicketObject.class
Any ideas?
Best Answer
TicketObject is an INNER class and thus you need to to use the following format