[SalesForce] How to put a list in the parameter for class and use its variables

I have a JSON and I need to pass the data to a list, then use it as my class parameter.

I've managed to pass JSON to a List, but when I put it in the class, it throws the following error:

"global methods do not support parameter type of List<contractFat.Contract>"

My code:

@RestResource(urlMapping='/updateFaturamento/*')
global  class contractFat { 

public class ContractJSON {

    public List<Contract> Contract;
}

    public class Contract {
        public String idSalesForce;
        public String dtEmissao;
        public String nrContrato;
        public String vlVenda;
        public String vlDevolucao;
        public String qtTotalClientes;
        public String qtClientesAtivosMes;
        public String flagMensal;
    }


    public  ContractJSON parse(String json) {
        return (ContractJSON) System.JSON.deserialize(json, ContractJSON.class);
    }
    @HttpPatch
    global static String updateFaturamento(List<Contract> Contratos)
    {
    RestRequest req = RestContext.request; 
    RestResponse res = RestContext.response;

Can anyone help me with this problem?

Best Answer

BTW - it's asking for trouble if you want to name an inner class "Contract" since this is also the name of a standard SObject.

But the error message is because contractFat.Contract has only public visibility yet it's used as a parameter in a global method.

Related Topic