I have this code:

global static String doPost() { 
    RestRequest req = RestContext.request;
    RestResponse res = RestContext.response;
    if(req.params.get('action') == 'create'){
        evticket__c ticket = createTicket(req);
        return 'yes';
        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){

    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?

1 Answer 1


TicketObject is an INNER class and thus you need to to use the following format

OUTERCLASS.TicketObject ticketObject = (OUTERCLASS.TicketObject)JSON.deserialize(req.requestbody.tostring(), OUTERCLASS.TicketObject.class);

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .