1.Currently working on Apex with the flow to pass the API data.
2.If I use @future(callout=true) in apex it throws an error like below.
Error: The only annotation that can be used with InvocableMethod is Deprecated
Apex
public class checkApi
{
@InvocableMethod(label='test' description='Getting customer info from test' )
@future(callout=true)
public static void abacuStagingsapi(List<id> appid)
{
Map<Id, Apple__c> app = new Map<Id, Apple__c>([SELECT id,Name,Contact__r.Email FROM
Apple__c WHERE Id IN :appid]);
for(Id Loanapp :appid){
String endpointurl ='https://th-apex-http-callout.herokuapp.com/animals';
Http http = new Http();
HttpRequest request = new HttpRequest();
request.setEndpoint(endpointurl);// update endpoint url
request.setMethod('GET');
request.setHeader('x-fern-token', '8IKxGlvbNQCciEpAYmz1yr1LM');
HttpResponse response = http.send(request);
System.debug(response.getBody());
// If the request is successful, parse the JSON response.
if (response.getStatusCode() == 200) {
system.debug('check'+ response.getStatus());
String result = String.valueof(response.getBody());
String[] emailList= new String[]{app.get(Loanapp)?.Contact__r.Email};
Messaging.SingleEmailMessage message = new Messaging.SingleEmailMessage();
String[] toAddressesTest = new List<String>(emailList);
message.setToAddresses(toAddressesTest);
message.setSubject('API Data');
message.setHtmlBody(result);
Messaging.SendEmail(new Messaging.SingleEmailMessage[] {message});
}
}
}
}
There is any resolve solution there?