I’ve installed the WP Discourse Plugin and everything seems to be working fine except the “Sync Comment Data” webhook. It keeps coming back as Failed with a Status Code: 400.
This is the response:
<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN">
<html><head>
<title>400 Bad Request</title>
</head><body>
<h1>Bad Request</h1>
<p>Your browser sent a request that this server could not understand.<br />
</p>
</body></html>
The payload URL seems to be correct.
Webhook Secret Key is set in both discourse and the WP plugin.
Double check that the payload URL and Webhook Secret Key are set correctly.
If that doesn’t fix the issue, can you let me know what permalink structure your WordPress site is using? The permalink structure is found on the Settings / Permalinks section of your WordPress dashboard.
What is the form of the URL you are adding to the webhook’s Payload URL field on Discourse? You can leave off the domain part of the URL. The URL that is given to you in the Sync Comment Data option’s description on WordPress should be correct (it is created based on the permalink structure that your site uses) but possibly it is wrong for your case.
One of the advertised features of the Ithemes Security plugin is that it can be used to block access to the Rest API. It would be worth confirming that this isn’t the cause of the issue.
You don’t need to use the Sync Comment Data webhook with the WP Discourse plugin. The main benefit of using it is that it allows comments to show up immediately after they are posted on Discourse instead of having to wait up to 10 minutes to fetch new comments. On very busy sites, the webhook can reduce the number of API requests that your site is making to Discourse. This mainly affects sites that display comment numbers on a post index page.
Yes, I have it working but I wanted to implement the webhooks to avoid the delay.
I checked with our developer and he said there’s no REST API blocking before he installed the security plugin or after. I’m baffled.
The screenshot you posted above is a good indication that the payload URL is correct. The 400 response code that you are getting indicates that the WordPress server is rejecting the request. If the issue was a mismatched secret key, you would be getting a 500 response code.
If you have access to your WordPress site’s Access Log file, it would probably show you exactly what the problem is.