I have list of accounts and want to use them for post request. How can I remove unnecessary fields like id to set that list in setbody? Now I am just using for loop and json serialize.
Some code. So I need remove id and some other fields. Maybe use Map with key?
Http http = new http();
HttpRequest request = new httprequest();
request.setHeader();
for(Account acc: accList){
String body = json.serialize(acc);
request.setbody(body);
}
Upd: AccList is just a list of recently created account records.It’s in trigger so Trigger.new.
accList
from? Your code sample is incomplete.