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
Pedro SallesPedro Salles 

How to put a list in the parameter for class and use its variables?

Hello everyone,
I am new to SF and am trying to solve the following problem:
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?

Thanks
 
Best Answer chosen by Pedro Salles
Raj VakatiRaj Vakati
RestResponse res = RestContext.response;
	// create a list of List<contractFat.Contract> 
	// convert the List<contractFat.Contract>into the jason string ... 
	
	// return the string 
	
	// some think like below 
	List<contractFat.Contract> lst = new List<contractFat.Contract>() ;
		// some think like below 

	String s = JSON.deserialize(lst) ;
	return s ;