+ Start a Discussion
Austin MayerhoferAustin Mayerhofer 

Setting up a Docparser webhook

Hi all, I'm working with a pdf parsing service called Docparser. I currently have functionality for sending POST and GET requests from my page to Docparser. Both work just fine. However, I'd like to set up a webhook so I don't have to send continuous GET requests, but rather have it send my code a POST request when parsing is finished.

Attached below is a picture of Docparser's setup for a Webhook. Docparser will be sending POST requests to my code.

I'm confused as to what I should put for the "Target URL" and "Additional Headers" though?

I've been doing some research and think I may need to set up my Apex code to handle requests. Such as this: https://trailhead.salesforce.com/en/content/learn/modules/apex_integration_services/apex_integration_webservices

Is this trailhead what I'm looking for? But also what would I eventually use as the Target URL and Additional Headers?

Any help is appreciated, thank you.

User-added image
AnudeepAnudeep (Salesforce Developers) 
You are looking at the correct Trailhead module. My understanding is you need to create a rest resource class and add this class to the site and give this public class URL to webhook. Webhook will post data to this class. You can access the data as shown below
 
@RestResource(urlMapping='/webhookResponse/*')
global class FirstAdvantageRestController {

    public static string restResponse='';
  
    @HttpPost
    global static string FAResponse()
    {
        RestRequest req = RestContext.request;
        String ipAddress = req.remoteAddress;
        Blob body = req.requestBody;
        system.debug('...................'+req);
        String bodyString = body.toString();
        system.debug('...................'+bodyString );
  }
}

If you find this information helpful, please mark this answer as Best. It may help others in the community. Thank You!

Anudeep