I am into a integration project and its new to me, till now I have share the standard Salesfroce REST API, apex class to get and post data from third party website. Now the third party webite as a api which I have to call when there is change in contact object. Could someone help me with this, its urgent
First of all, you need to add the third-party service to Remote Site Settings (Setup -> Remote Site Settings).
Next implement a trigger on Contact (before or after update). Callouts from triggers are not supported (note this). Make a map with any necessary for third-party service info and provide it to the @future(callout=true) method in some controller apex class.
In the future method you can run callouts like this:
Http http = new Http(); HttpRequest request = new HttpRequest(); request.setMethod(method); request.setEndpoint(endpoint); HttpResponse response = http.send(request);
More information can be found here: https://trailhead.salesforce.com/en/content/learn/modules/apex_integration_services/apex_integration_rest_callouts
When there is update in contact object, you have to inovke the external API. Before jumping into trigger, I would say first try to invoke 3rd party api using workflow outbound message action when contact record updated as rule criteria in workflow.
Or invoke process builder when contact is updated and from Process builder invoke the apex class method(@Invokable method) and pass the required parameters and do the callout from apex.