How to create a webhook for Appsearch from Contentful

HI, I have created a webhook from contentful cms like below, using post method.

POST: https://host-ucy3pj.api.swiftype.com/api/as/v1/engines/national-parks-demo/documents.

But it fails to send data into the Appsearch. Below is the error I get in the Response body.

Response body

{ "error": "You need to sign in or sign up before continuing." }

With a status : "status": "401 Unauthorized".

Obviously I can understand we need to send the private key as well. However when I try to add the private key in the options, my contentful does not accept, it throws error "Please provide a valid webhook URL." when I try to set the webhook in the below format.

https://host-ucy3pj.api.swiftype.com/api/as/v1/engines/national-parks-demo/documents -H 'Content-Type: application/json'  -H 'Authorization: Bearer private-REDACTED'

Could you please suggest how to create a webhook from any system into the Appsearch Endpoint? This is very crucial for our project as we intend to send the data from our contentful into the Appsearch, and then our MobileApp must be able to show results from the Appsearch index.

Please provide your valuable inputs.

Hey @venu.pgi. So excited to hear you're using Swiftype with Contentful. I think they make a great match.

The thing you may be missing in your webhook is this; your API key needs to be added with in the "Authorization" header, and prefixed with "Bearer ". So it would look like:

Authorization: Bearer private-xxxxxxxxxxxxxxxxxxxx

I just went through the process of creating an Index Webhook for a content type of Article. Here is what mine looked like, for reference:

Let me know how this project goes. I'd love to hear more about the integration with Contentful.

1 Like

@venu.pgi You should also change your private key within your Account ASAP, since you've posted it publicly in this thread. That private key gives anyone access to make changes to your Account's engines. Let us know if you need help doing that.

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.