function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
PankajJhaPankajJha 

How to create webhooks in salesforce ?

Hi Friends, I am new to integration and my task is
How to create webhooks in salesforce ?
thanks in advance.
ANUTEJANUTEJ (Salesforce Developers) 
Hi Pankaj,

I found the below link for creating webhooks [https://www.jamesward.com/2014/06/30/create-webhooks-on-salesforce-com] I hope this is useful for you in your implementation In case if you have used this can you please choose this as the best answer so that it is useful for others in the future.

Regards,
Anutej
sachinarorasfsachinarorasf
Hi PankajJha,

I have gone through your problem.

Go through the below links:

1.https://www.jamesward.com/2014/06/30/create-webhooks-on-salesforce-com
2.https://www.youtube.com/watch?v=JEknJb-j6gY
3.https://salesforce-webhook-creator.herokuapp.com/

I hope you find the above solution helpful. If it does, please mark as Best Answer to help others too.

Thanks and Regards,
Sachin Arora
PankajJhaPankajJha
@sachinarorasf
@ANUTEJ
i need a public webhook or custom webhook with code.
How to create webhooks in salesforce ?
 
Ashima Gupta 9Ashima Gupta 9
Any breakthrough PankajJha? I am also looking for something similar.

Appreciate your response. 
Adam Zuckerman 3Adam Zuckerman 3

So there's a few ways your could approach this. If you want to go the custom code route, the general approach I use is to create a wrapper for the request like the following:

public class SomeRequest {
    public string record_id { get; set; }
}

And then use JSON Class serialize method (https://developer.salesforce.com/docs/atlas.en-us.apexref.meta/apexref/apex_class_System_Json.htm#apex_System_Json_serialize) to create your JSON payload.

You usually do something similar for the response except you'll deserialize (https://developer.salesforce.com/docs/atlas.en-us.apexref.meta/apexref/apex_class_System_Json.htm#apex_System_Json_deserialize) the response into your response wrapper.

You'll also have to make some type of HTTP request like the following:

Http h = new Http();
HttpRequest req = new HttpRequest();
req.setHeader('Accept', 'application/json');
req.setHeader('Content-Type', 'application/json');
req.setEndpoint(url);
req.setMethod('POST');
req.setTimeout(30000);
req.setBody(someBody);

HttpResponse res;
res = h.send(req);
Typically, you will call your API/webhook methods asynchronously within a future method called from an Apex trigger.

Let me know if you need any more specific nitty gritty help. Also, there are some AppExchange apps which can make this way easier like Declarative Webhooks (https://appexchange.salesforce.com/appxListingDetail?listingId=a0N3u00000MSv8REAT).
Shehzad AkbarShehzad Akbar

Hi!

Typically, the way to set this up is by:

1. Creating triggers on the Salesforce Objects you want to get updates for
2. Write Apex class that will send an outgoing message to a pre-determined URL
3. Enable Remote Site Setting for the Domain you want to send the message to
4. Add in Secret Verification (or other auth method) to prevent spamming of your external URL
5. Ensure 70% test coverage of your Apex Classes

If you're just looking for an easy way to set this up without having to jump through the hoops, fusebit packages it nicely in a free 1-click installation, you can read through the docs and see the video walkthrough here: https://developer.fusebit.io/docs/salesforce-events