You can make a callout from the apex trigger and based on the response received you can deserialize and map it to the corresponding fields on the object to update. But make sure you might get the recursion issue inorder to update.
Trigger:
trigger CurrencyConversionUpdate on CurrencyConversion__c (before insert,before update) {
for (CurrencyConversion__c cc : Trigger.new) {
if (any condition) {
CurrencyCoversioncall.Integrationccupdate(cc.Id);
System.debug('cc.Id');
}
}
HTTP Class to POST To an External URL:
global class CurrencyCoversioncall {
@future (callout=true)
public static void Integrationccupdate(id ccid) {
//Construct HTTP request and response
//Http request method,Endpoint and setBody
HttpRequest req = new HttpRequest();
req.setHeader('Content-Type','application/json');
String endpoint = 'Endpoint URL FOR External service';
req.setMethod('POST');
req.setEndpoint(endpoint);
system.debug('CC ID' +ccid);
//SOQL to construct JSON string in set body
CurrencyConversion__c cc=[select id,Name, Input_Currency__c from CurrencyConversion__c where id=:ccid];
system.debug('without pretty'+JSON.serialize(cc));
String JsonString=JSON.serialize(cc);
req.setBody(JsonString);
system.debug(JsonString);
//Http response method
Http http = new Http();
HTTPResponse res = http.send(req);
System.debug(res.getBody());
}
}