Invoke Apex API callout class with a flow #inSalesforce
Setup | Remote Site Settings | New Remote Site | Enter the Remote Site Name (like Callout) and URL(like https://th-apex-http-callout.herokuapp.com/animals/) | Select Active | Save
Create a Class like:
Public class calloutClassSample{
@InvocableMethod(label='APICALL' callout='True')
Public static void apiCall(List<String> demo){
Http h = new Http();
HttpRequest req = new HttpRequest();
req.setEndpoint('https://th-apex-http-callout.herokuapp.com/animals/');
req.setMethod('GET');
HttpResponse res= h.send(req);
//return res.getBody();
//system.debug('getResponse'+res.getBody());
}
}
@InvocableMethod(label='APICALL' callout='True')
Public static void apiCall(List<String> demo){
Http h = new Http();
HttpRequest req = new HttpRequest();
req.setEndpoint('https://th-apex-http-callout.herokuapp.com/animals/');
req.setMethod('GET');
HttpResponse res= h.send(req);
//return res.getBody();
//system.debug('getResponse'+res.getBody());
}
}
Create a flow:
Create a record triggered flow, Object - Account, on Update, Criteria - Active__c equals True and Industry equals Chemicals, ISCHANGED True or Only when a record is updated to meet the condition requirements selected, Make sure that Include a Run asynchronously path to access... is checked
Add Action:
Label it APICALL and demo value is 1
Label it APICALL and demo value is 1
Apex Action: APICALL
Connect the flow, Run Asynchronously Save, and Debug
While debugging, you can debug by skipping the start conditions, selecting the account and running.
Now check the logs to view the response in the developer console (You may select debug only while viewing)
Visual: https://www.youtube.com/watch?v=u8FtSOVWcgE
Comments
Post a Comment